From 1a06b0cea6151804e54f782e7dc17ededcb3e94c Mon Sep 17 00:00:00 2001 From: "Timothy J. Baek" Date: Thu, 18 Jan 2024 16:38:47 -0800 Subject: [PATCH] fix: old chat log import issue --- src/lib/components/chat/SettingsModal.svelte | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/lib/components/chat/SettingsModal.svelte b/src/lib/components/chat/SettingsModal.svelte index c79fe1068..bd80cd598 100644 --- a/src/lib/components/chat/SettingsModal.svelte +++ b/src/lib/components/chat/SettingsModal.svelte @@ -142,13 +142,20 @@ importChats(chats); }; - reader.readAsText(importFiles[0]); + if (importFiles.length > 0) { + reader.readAsText(importFiles[0]); + } } const importChats = async (_chats) => { for (const chat of _chats) { console.log(chat); - await createNewChat(localStorage.token, chat.chat); + + if (chat.chat) { + await createNewChat(localStorage.token, chat.chat); + } else { + await createNewChat(localStorage.token, chat); + } } await chats.set(await getChatList(localStorage.token));