浏览代码

Merge pull request #522 from ollama-webui/import-chat-fix

fix: old chat log import issue
Timothy Jaeryang Baek 1 年之前
父节点
当前提交
ff33aa37ae
共有 1 个文件被更改,包括 9 次插入2 次删除
  1. 9 2
      src/lib/components/chat/SettingsModal.svelte

+ 9 - 2
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));