Skip to content

Commit

Permalink
fix(database): storage should be accessed via globalThis (#8863)
Browse files Browse the repository at this point in the history
  • Loading branch information
zzj3720 committed Dec 5, 2024
1 parent 4f02d3a commit a790250
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/blocks/src/database-block/utils/current-view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ const currentViewListSchema = z.array(
);
const maxLength = 20;
const currentViewListKey = 'blocksuite:databaseBlock:view:currentViewList';
const storage = globalThis.sessionStorage;
const createCurrentViewStorage = () => {
const getList = () => {
const string = localStorage.getItem(currentViewListKey);
const string = storage?.getItem(currentViewListKey);
if (!string) {
return;
}
Expand All @@ -25,7 +26,7 @@ const createCurrentViewStorage = () => {
return;
};
const saveList = () => {
localStorage.setItem(currentViewListKey, JSON.stringify(list));
storage.setItem(currentViewListKey, JSON.stringify(list));
};

const list = getList() ?? [];
Expand Down

0 comments on commit a790250

Please sign in to comment.