chore: improve ux of fetching course
This commit is contained in:
@@ -88,6 +88,9 @@
|
|||||||
return goto('/login?redirect=/' + path);
|
return goto('/login?redirect=/' + path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Skip refetching profile, if already in store
|
||||||
|
if ($profile.id) return;
|
||||||
|
|
||||||
// Check if user has profile
|
// Check if user has profile
|
||||||
let {
|
let {
|
||||||
data: profileData,
|
data: profileData,
|
||||||
|
|||||||
@@ -19,7 +19,10 @@
|
|||||||
if (hasFetched || !userId || !orgId) {
|
if (hasFetched || !userId || !orgId) {
|
||||||
return;
|
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);
|
const coursesResult = await fetchCourses(userId, orgId);
|
||||||
console.log(`coursesResult`, coursesResult);
|
console.log(`coursesResult`, coursesResult);
|
||||||
|
|||||||
@@ -27,12 +27,15 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function getCourses(userId: string | null, orgId: string) {
|
async function getCourses(userId: string | null, orgId: string) {
|
||||||
console.log('hasFetched', hasFetched);
|
|
||||||
if (hasFetched || !userId || !orgId) {
|
if (hasFetched || !userId || !orgId) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
hasFetched = true;
|
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);
|
const coursesResult = await fetchCourses(userId, orgId);
|
||||||
console.log(`get courses result`, coursesResult);
|
console.log(`get courses result`, coursesResult);
|
||||||
|
|||||||
@@ -30,7 +30,10 @@
|
|||||||
|
|
||||||
async function getCourses(userId: string | null, orgId: string) {
|
async function getCourses(userId: string | null, orgId: string) {
|
||||||
if (cantFetch && typeof cantFetch === 'boolean' && !allCourses.length && orgId && !hasFetched) {
|
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);
|
const coursesResult = await fetchCourses(userId, orgId);
|
||||||
console.log(`coursesResult`, coursesResult);
|
console.log(`coursesResult`, coursesResult);
|
||||||
|
|||||||
Reference in New Issue
Block a user