Skip to content

Commit

Permalink
dashboard client: prevent infinite "Loading" when there are no classe…
Browse files Browse the repository at this point in the history
…s/challenges
  • Loading branch information
HolecekM committed Dec 16, 2024
1 parent 4b750c9 commit 95174b0
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion dashboard/client/src/SideNavBar.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
{#if visible}
<div transition:slide={{ axis: 'x' }} class="sidebar pt-5 flex-shrink-0">
<button type="button" class="btn-close close-btn" on:click={() => (visible = false)}></button>
{#if !($challenges.length && $classes.length)}
{#if !($challenges && $classes)}
<div class="spinner-border" role="status">
<span class="visually-hidden">Loading...</span>
</div>
Expand Down
4 changes: 2 additions & 2 deletions dashboard/client/src/routing.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ export const chosenChallenge = derived([challenges, path], ([challenges, path])
const match = path.match(/^#challenge\/(.+)$/);
if (!match) return null;

return challenges.find((chall) => chall.id === match[1]) ?? null;
return challenges?.find((chall) => chall.id === match[1]) ?? null;
});

export const chosenClass = derived([classes, path], ([classes, path]) => {
const match = path.match(/^#class\/(.+)$/);
if (!match) return null;

return classes.find((cls) => cls.id === match[1]) ?? null;
return classes?.find((cls) => cls.id === match[1]) ?? null;
});
4 changes: 2 additions & 2 deletions dashboard/client/src/stores.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { get, writable } from 'svelte/store';

export const isLoading = writable(false);

export const classes = writable([]);
export const challenges = writable([]);
export const classes = writable(null);
export const challenges = writable(null);

export const storageBackedWritable = (key, defaultData) => {
const store = writable(localStorage.getItem(key) ?? defaultData);
Expand Down

0 comments on commit 95174b0

Please sign in to comment.