Skip to content

Commit

Permalink
fix: fix remove item from storage bug
Browse files Browse the repository at this point in the history
  • Loading branch information
NekoLyn committed Jan 6, 2025
1 parent 10a1914 commit 4cf820b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/utils/StorageUtils.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { isDraft } from "immer";
import { current } from "@reduxjs/toolkit";

const BOOKMARK_IDS_KEY = "bookmark-list";
Expand All @@ -10,7 +11,7 @@ export const saveBookmarkIdsToStorage = (items: Array<any>) => {
}

// Convert from Immer draft if necessary
const plainItems = current(items);
const plainItems = isDraft(items) ? current(items) : items;
const ids = plainItems.map((item) => item.id);
localStorage.setItem(BOOKMARK_IDS_KEY, JSON.stringify(ids));
} catch (e) {
Expand Down

0 comments on commit 4cf820b

Please sign in to comment.