diff --git a/src/components/Option/Settings/other.tsx b/src/components/Option/Settings/other.tsx index e33b389..edb4349 100644 --- a/src/components/Option/Settings/other.tsx +++ b/src/components/Option/Settings/other.tsx @@ -116,7 +116,7 @@ export const SettingOther = () => { if (confirm) { const db = new PageAssitDatabase() - await db.deleteChatHistory() + await db.deleteAllChatHistory() queryClient.invalidateQueries({ queryKey: ["fetchChatHistory"] }) diff --git a/src/db/index.ts b/src/db/index.ts index 088038a..1b85d11 100644 --- a/src/db/index.ts +++ b/src/db/index.ts @@ -121,6 +121,14 @@ export class PageAssitDatabase { this.db.remove(id) } + async deleteAllChatHistory() { + const chatHistories = await this.getChatHistories() + chatHistories.forEach((history) => { + this.db.remove(history.id) + }) + this.db.set({ chatHistories: [] }) + } + async deleteMessage(history_id: string) { await this.db.remove(history_id) } @@ -456,4 +464,4 @@ export const importPrompts = async (prompts: Prompts) => { for (const prompt of prompts) { await db.addPrompt(prompt) } -} \ No newline at end of file +}