Timothy J. Baek 6 月之前
父節點
當前提交
cad31f6f2b
共有 1 個文件被更改,包括 6 次插入7 次删除
  1. 6 7
      src/lib/components/layout/Sidebar/ChatMenu.svelte

+ 6 - 7
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'
 		});