tanstack-cacher 1.6.2 → 1.6.3
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.
- package/index.js +3 -3
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -526,7 +526,7 @@ var usePaginatedCacheActions = ({
|
|
|
526
526
|
const totalElements = getAtPath(old, totalElementsPath, 0);
|
|
527
527
|
const pageSize = getAtPath(old, pageSizePath, 10);
|
|
528
528
|
const newTotal = totalElements + 1;
|
|
529
|
-
const newItems = [item, ...items];
|
|
529
|
+
const newItems = [item, ...items].slice(0, pageSize);
|
|
530
530
|
let result = { ...old };
|
|
531
531
|
result = setAtPath(result, itemsPath, newItems);
|
|
532
532
|
result = setAtPath(result, totalElementsPath, newTotal);
|
|
@@ -554,13 +554,13 @@ var usePaginatedCacheActions = ({
|
|
|
554
554
|
const index = items.findIndex((i) => i.id === id);
|
|
555
555
|
if (index === -1) return old;
|
|
556
556
|
const newItems = items.filter((i) => i.id !== id);
|
|
557
|
-
const currentPage = getAtPath(old, currentPagePath,
|
|
557
|
+
const currentPage = getAtPath(old, currentPagePath, defaultPage);
|
|
558
558
|
const totalElements = getAtPath(old, totalElementsPath, 0);
|
|
559
559
|
const pageSize = getAtPath(old, pageSizePath, 10);
|
|
560
560
|
const totalPages = getAtPath(old, totalPagesPath, 1);
|
|
561
561
|
const newTotal = Math.max(0, totalElements - 1);
|
|
562
562
|
const newTotalPages = Math.ceil(newTotal / pageSize);
|
|
563
|
-
if (newItems.length === 0 && currentPage >
|
|
563
|
+
if (newItems.length === 0 && currentPage > defaultPage) {
|
|
564
564
|
onNavigateToPage?.(currentPage - 1);
|
|
565
565
|
} else if (newItems.length > 0 && newItems.length <= refetchThreshold && totalPages > currentPage) {
|
|
566
566
|
shouldRefetch = true;
|
package/package.json
CHANGED