浏览代码

fix: temp chat json export

Timothy Jaeryang Baek 3 月之前
父节点
当前提交
c8be0ee1e0
共有 1 个文件被更改,包括 12 次插入5 次删除
  1. 12 5
      src/lib/components/layout/Navbar/Menu.svelte

+ 12 - 5
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`);
 	};
 </script>