@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 + re-fetch on page/search/filter change via cache
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
- (async () => {
425
- try {
426
- const { count, items } = await getCachedClasses({ params: listParams });
427
- dispatch({
428
- type: CLASS_ACTION_TYPES.SET_ITEMS,
429
- payload: { items: items || [], count: count || 0 },
430
- });
431
- }
432
- catch (_a) {
433
- showToast(t("messagesFetchFailed"), TOAST_VARIANT.ERROR);
434
- }
435
- })();
436
- }, [dispatch, listParams, schoolId, showToast, t]);
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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@appcorp/fusion-storybook",
3
- "version": "0.1.76",
3
+ "version": "0.1.77",
4
4
  "scripts": {
5
5
  "build-storybook": "storybook build",
6
6
  "build:next": "next build",