diff --git a/frontend/fic/src/routes/+page.svelte b/frontend/fic/src/routes/+page.svelte index c54dc5a6..1ace6043 100644 --- a/frontend/fic/src/routes/+page.svelte +++ b/frontend/fic/src/routes/+page.svelte @@ -35,33 +35,39 @@ } if ($themesStore["0"] && !$themesStore["0"].locked && $themesStore["0"].exercices) { - let nb_ex_max = tmpitems.length; - let i = 1; - let j = 0; - for (j = $themesStore["0"].exercices.length - 1; j >= 0 && i < tmpitems.length; j--) { - if ($my && $my.team_id && !$my.exercices[$themesStore["0"].exercices[j].id]) { - // Only apply after start - if (!($time.startIn && j < nb_ex_max && j < $settings.unlockedStandaloneExercices)) + if (tmpitems.length) { + let nb_ex_max = tmpitems.length; + let i = 1; + let j = 0; + for (j = $themesStore["0"].exercices.length - 1; j >= 0 && i < tmpitems.length; j--) { + if ($my && $my.team_id && !$my.exercices[$themesStore["0"].exercices[j].id]) { + // Only apply after start + if (!($time.startIn && j < nb_ex_max && j < $settings.unlockedStandaloneExercices)) + continue; + } else if ($my && !$my.team_id && j >= nb_ex_max) { continue; - } else if ($my && !$my.team_id && j >= nb_ex_max) { - continue; + } + + tmpitems.splice(i, 0, {id: tmpitems.length, theme: $themesStore["0"], exercice: $themesStore["0"].exercices[j]}); + i += 2; } - tmpitems.splice(i, 0, {id: tmpitems.length, theme: $themesStore["0"], exercice: $themesStore["0"].exercices[j]}); - i += 2; - } - - if (j >= 0 || i == 1) { - tmpitems.push({ - id: tmpitems.length, - theme: { - ...$themesStore["0"], - name: "Voir les autres défis", - headline: "Il y a " + ($themesStore["0"].exercices.length) + " défis à découvrir ! Cliquez ici pour les afficher.", - locked: $themesStore["0"].locked || i == 1, - }, - color: "light", - }); + if (j >= 0 || i == 1) { + tmpitems.push({ + id: tmpitems.length, + theme: { + ...$themesStore["0"], + name: "Voir les autres défis", + headline: "Il y a " + ($themesStore["0"].exercices.length) + " défis à découvrir ! Cliquez ici pour les afficher.", + locked: $themesStore["0"].locked || i == 1, + }, + color: "light", + }); + } + } else { + for (const j in $themesStore["0"].exercices) { + tmpitems.push({id: tmpitems.length, theme: $themesStore["0"], exercice: $themesStore["0"].exercices[j]}); + } } }