@appcorp/fusion-storybook 0.1.76 → 0.1.77
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -417,23 +417,37 @@ export const useClassModule = () => {
|
|
|
417
417
|
// ============================================================================
|
|
418
418
|
// 1.4.9 EFFECTS
|
|
419
419
|
// ============================================================================
|
|
420
|
-
// Initial load
|
|
420
|
+
// Initial load via cache; re-fetch directly from API on page/pageLimit/filter/search changes
|
|
421
421
|
useEffect(() => {
|
|
422
422
|
if (!schoolId)
|
|
423
423
|
return;
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
424
|
+
const currentPage = Number(listParams.currentPage) || 1;
|
|
425
|
+
const currentPageLimit = Number(listParams.pageLimit) || pageLimit;
|
|
426
|
+
const isDefaultLoad = currentPage === 1 &&
|
|
427
|
+
currentPageLimit === pageLimit &&
|
|
428
|
+
!listParams.searchQuery &&
|
|
429
|
+
listParams.filterEnabled === undefined;
|
|
430
|
+
if (isDefaultLoad) {
|
|
431
|
+
(async () => {
|
|
432
|
+
try {
|
|
433
|
+
const { count, items } = await getCachedClasses({
|
|
434
|
+
params: listParams,
|
|
435
|
+
});
|
|
436
|
+
dispatch({
|
|
437
|
+
type: CLASS_ACTION_TYPES.SET_ITEMS,
|
|
438
|
+
payload: { items: items || [], count: count || 0 },
|
|
439
|
+
});
|
|
440
|
+
}
|
|
441
|
+
catch (_a) {
|
|
442
|
+
showToast(t("messagesFetchFailed"), TOAST_VARIANT.ERROR);
|
|
443
|
+
}
|
|
444
|
+
})();
|
|
445
|
+
}
|
|
446
|
+
else {
|
|
447
|
+
// Bypass cache for pagination, pageLimit, filter and search changes
|
|
448
|
+
listFetchNow();
|
|
449
|
+
}
|
|
450
|
+
}, [dispatch, listFetchNow, listParams, schoolId, showToast, t]);
|
|
437
451
|
// Sync ref to always point at latest listFetchNow (avoids stale closure in callbacks)
|
|
438
452
|
useEffect(() => {
|
|
439
453
|
listFetchNowRef.current = listFetchNow;
|