From 2d1895c360bb579b77a9ca65eeb29d4809747d7c Mon Sep 17 00:00:00 2001 From: Connor Cleveland Date: Sun, 29 Oct 2023 01:27:40 -0500 Subject: [PATCH] Fix empty filters saving to hash --- client/src/utils/saveload.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/client/src/utils/saveload.ts b/client/src/utils/saveload.ts index 35d2dbe..28184b6 100644 --- a/client/src/utils/saveload.ts +++ b/client/src/utils/saveload.ts @@ -18,18 +18,18 @@ export function useInitialTableState(tableId: string): TableState { const savedSorters = hasHashProperty("sorters") ? getHashProperty("sorters") : isLocalStorageAvailable - ? localStorage.getItem(`${tableId}-sorters`) - : null; + ? localStorage.getItem(`${tableId}-sorters`) + : null; const savedFilters = hasHashProperty("filters") ? getHashProperty("filters") : isLocalStorageAvailable - ? localStorage.getItem(`${tableId}-filters`) - : null; + ? localStorage.getItem(`${tableId}-filters`) + : null; const savedPagination = hasHashProperty("pagination") ? getHashProperty("pagination") : isLocalStorageAvailable - ? localStorage.getItem(`${tableId}-pagination`) - : null; + ? localStorage.getItem(`${tableId}-pagination`) + : null; const savedShowColumns = isLocalStorageAvailable ? localStorage.getItem(`${tableId}-showColumns`) : null; const sorters = savedSorters ? JSON.parse(savedSorters) : [{ field: "id", order: "asc" }]; @@ -59,7 +59,7 @@ export function useStoreInitialState(tableId: string, state: TableState) { if (filters.length > 0) { if (isLocalStorageAvailable) { localStorage.setItem(`${tableId}-filters`, JSON.stringify(filters)); - setURLHash("filters", JSON.stringify(state.filters)); + setURLHash("filters", JSON.stringify(filters)); } } else { localStorage.removeItem(`${tableId}-filters`);