diff --git a/apps/dashboard/src/routes/+layout.svelte b/apps/dashboard/src/routes/+layout.svelte index 8c4f4388..5dfe35cf 100644 --- a/apps/dashboard/src/routes/+layout.svelte +++ b/apps/dashboard/src/routes/+layout.svelte @@ -88,6 +88,9 @@ return goto('/login?redirect=/' + path); } + // Skip refetching profile, if already in store + if ($profile.id) return; + // Check if user has profile let { data: profileData, diff --git a/apps/dashboard/src/routes/lms/+page.svelte b/apps/dashboard/src/routes/lms/+page.svelte index 384a6d90..ae8cb73b 100644 --- a/apps/dashboard/src/routes/lms/+page.svelte +++ b/apps/dashboard/src/routes/lms/+page.svelte @@ -19,7 +19,10 @@ if (hasFetched || !userId || !orgId) { return; } - $courseMetaDeta.isLoading = true; + // only show is loading when fetching for the first time + if (!$courses.length) { + $courseMetaDeta.isLoading = true; + } const coursesResult = await fetchCourses(userId, orgId); console.log(`coursesResult`, coursesResult); diff --git a/apps/dashboard/src/routes/lms/mylearning/+page.svelte b/apps/dashboard/src/routes/lms/mylearning/+page.svelte index 05c22f5c..99198777 100644 --- a/apps/dashboard/src/routes/lms/mylearning/+page.svelte +++ b/apps/dashboard/src/routes/lms/mylearning/+page.svelte @@ -27,12 +27,15 @@ } async function getCourses(userId: string | null, orgId: string) { - console.log('hasFetched', hasFetched); if (hasFetched || !userId || !orgId) { return; } hasFetched = true; - $courseMetaDeta.isLoading = true; + + // only show is loading when fetching for the first time + if (!$courses.length) { + $courseMetaDeta.isLoading = true; + } const coursesResult = await fetchCourses(userId, orgId); console.log(`get courses result`, coursesResult); diff --git a/apps/dashboard/src/routes/org/[slug]/courses/+page.svelte b/apps/dashboard/src/routes/org/[slug]/courses/+page.svelte index a501b027..86b4dccc 100644 --- a/apps/dashboard/src/routes/org/[slug]/courses/+page.svelte +++ b/apps/dashboard/src/routes/org/[slug]/courses/+page.svelte @@ -30,7 +30,10 @@ async function getCourses(userId: string | null, orgId: string) { if (cantFetch && typeof cantFetch === 'boolean' && !allCourses.length && orgId && !hasFetched) { - $courseMetaDeta.isLoading = true; + // only show is loading when fetching for the first time + if (!$courses.length) { + $courseMetaDeta.isLoading = true; + } const coursesResult = await fetchCourses(userId, orgId); console.log(`coursesResult`, coursesResult);