From c8be0ee1e0d07079fdfc5c8ff20db21e30aa0e24 Mon Sep 17 00:00:00 2001 From: Timothy Jaeryang Baek Date: Sun, 5 Jan 2025 01:10:45 -0800 Subject: [PATCH] fix: temp chat json export --- src/lib/components/layout/Navbar/Menu.svelte | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/lib/components/layout/Navbar/Menu.svelte b/src/lib/components/layout/Navbar/Menu.svelte index 67ac9dcb2..e31064973 100644 --- a/src/lib/components/layout/Navbar/Menu.svelte +++ b/src/lib/components/layout/Navbar/Menu.svelte @@ -83,12 +83,19 @@ const downloadJSONExport = async () => { if (chat.id) { - chat = await getChatById(localStorage.token, chat.id); + let chatObj = null; + + if (chat.id === 'local' || $temporaryChatEnabled) { + chatObj = chat; + } else { + chatObj = await getChatById(localStorage.token, chat.id); + } + + let blob = new Blob([JSON.stringify([chatObj])], { + type: 'application/json' + }); + saveAs(blob, `chat-export-${Date.now()}.json`); } - let blob = new Blob([JSON.stringify([chat])], { - type: 'application/json' - }); - saveAs(blob, `chat-export-${Date.now()}.json`); };