From cad31f6f2bf3d2329204091007257956b5705152 Mon Sep 17 00:00:00 2001 From: "Timothy J. Baek" Date: Fri, 18 Oct 2024 14:08:43 -0700 Subject: [PATCH] fix --- src/lib/components/layout/Sidebar/ChatMenu.svelte | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/lib/components/layout/Sidebar/ChatMenu.svelte b/src/lib/components/layout/Sidebar/ChatMenu.svelte index 458e1c895..e983818cd 100644 --- a/src/lib/components/layout/Sidebar/ChatMenu.svelte +++ b/src/lib/components/layout/Sidebar/ChatMenu.svelte @@ -50,12 +50,7 @@ pinned = await getChatPinnedStatusById(localStorage.token, chatId); }; - const getChatAsText = async () => { - const chat = await getChatById(localStorage.token, chatId); - if (!chat) { - return; - } - + const getChatAsText = async (chat) => { const history = chat.chat.history; const messages = createMessagesList(history, history.currentId); const chatText = messages.reduce((a, message, i, arr) => { @@ -66,8 +61,12 @@ }; const downloadTxt = async () => { - const chatText = await getChatAsText(); + const chat = await getChatById(localStorage.token, chatId); + if (!chat) { + return; + } + const chatText = await getChatAsText(chat); let blob = new Blob([chatText], { type: 'text/plain' });