Skip to content

Commit

Permalink
fix: clear only table's storage entries
Browse files Browse the repository at this point in the history
  • Loading branch information
schummar committed Sep 9, 2022
1 parent 49bfea2 commit 9156968
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 15 deletions.
6 changes: 6 additions & 0 deletions docs/stories/Intro.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,9 @@ export const SortDisabledOne = {
})),
},
};

export const Persitance = {
args: {
persist: { storage: localStorage, id: 'tablePersitance' },
},
};
17 changes: 2 additions & 15 deletions src/internalState/tableStateStorage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,21 +189,8 @@ export function useTableStateStorage(table: Store<InternalTableState<any>>) {
return;
}

const { storage } = persist;
const keys =
'keys' in storage
? await storage.keys()
: await Promise.all(
Array(storage.length)
.fill(0)
.map((_x, i) => storage.key(i)),
);

for (const key of keys) {
if (key !== null) {
await storage.removeItem(key);
}
}
const { storage, id } = persist;
await storage.removeItem(storageName(id));

q.clear();
});
Expand Down

0 comments on commit 9156968

Please sign in to comment.