qa: Fix load functions not awaited since SvelteKit 2

This commit is contained in:
nemunaire 2024-02-09 16:41:02 +01:00
parent 81cd6fe3a1
commit fb6a5d8063
3 changed files with 10 additions and 8 deletions

View file

@ -3,11 +3,12 @@ import { getExerciceQA } from '$lib/qa.js';
/** @type {import('./$types').PageLoad} */ /** @type {import('./$types').PageLoad} */
export async function load({ depends, params }) { export async function load({ depends, params }) {
const exercice = getExercice(params.eid) const [exercice, qaitems] = await Promise.all([
depends(`api/exercices/${params.eid}`); getExercice(params.eid),
getExerciceQA(params.eid),
const qaitems = getExerciceQA(params.eid); ]);
depends(`api/exercices/${params.eid}/qa`); depends(`api/exercices/${params.eid}/qa`);
depends(`api/exercices/${params.eid}`);
return { exercice, qaitems }; return { exercice, qaitems };
} }

View file

@ -2,7 +2,7 @@ import { getTheme } from '$lib/themes';
/** @type {import('./$types').PageLoad} */ /** @type {import('./$types').PageLoad} */
export async function load({ depends, params }) { export async function load({ depends, params }) {
const theme = getTheme(params.tid) const theme = await getTheme(params.tid)
depends(`api/themes/${params.tid}`); depends(`api/themes/${params.tid}`);
return { theme }; return { theme };

View file

@ -5,10 +5,11 @@ import { getExerciceQA } from '$lib/qa.js';
export async function load({ depends, params, parent }) { export async function load({ depends, params, parent }) {
const { theme } = await parent(); const { theme } = await parent();
const exercice = getExercice(params.eid) const [exercice, qaitems] = await Promise.all([
getExercice(params.eid),
getExerciceQA(params.eid),
]);
depends(`api/exercices/${params.eid}`); depends(`api/exercices/${params.eid}`);
const qaitems = getExerciceQA(params.eid);
depends(`api/exercices/${params.eid}/qa`); depends(`api/exercices/${params.eid}/qa`);
return { exercice, qaitems, theme }; return { exercice, qaitems, theme };