diff --git a/app/store/chat.ts b/app/store/chat.ts index ffaf8c9966f..a6e4ee796a7 100644 --- a/app/store/chat.ts +++ b/app/store/chat.ts @@ -27,7 +27,7 @@ import { createPersistStore } from "../utils/store"; import { collectModelsWithDefaultModel } from "../utils/model"; import { useAccessStore } from "./access"; import { isDalle3 } from "../utils"; -import { clear } from "idb-keyval"; +import { indexDBStorage } from "@/app/utils/indexDB-storage"; export type ChatMessage = RequestMessage & { date: string; @@ -667,7 +667,7 @@ export const useChatStore = createPersistStore( }, async clearAllData() { - await clear(); + await indexDBStorage.clear(); localStorage.clear(); location.reload(); }, diff --git a/app/utils/indexDB-storage.ts b/app/utils/indexDB-storage.ts index ef99279232c..5dee4c856cc 100644 --- a/app/utils/indexDB-storage.ts +++ b/app/utils/indexDB-storage.ts @@ -1,9 +1,7 @@ import { StateStorage } from "zustand/middleware"; -import { get, set, del } from "idb-keyval"; +import { get, set, del, clear } from "idb-keyval"; class IndexDBStorage implements StateStorage { - constructor() {} - public async getItem(name: string): Promise { return (await get(name)) || localStorage.getItem(name); } @@ -15,6 +13,10 @@ class IndexDBStorage implements StateStorage { public async removeItem(name: string): Promise { await del(name); } + + public async clear(): Promise { + await clear(); + } } export const indexDBStorage = new IndexDBStorage();