diff --git a/app/components/settings.tsx b/app/components/settings.tsx index e1aa7cf6734..3acd7477708 100644 --- a/app/components/settings.tsx +++ b/app/components/settings.tsx @@ -51,6 +51,7 @@ import Locale, { import { copyToClipboard, downloadAs, + readFromFile, } from "../utils"; import Link from "next/link"; import { @@ -611,6 +612,21 @@ function LocalDataModal(props: { onClose?: () => void }) { await downloadAs(sessions, fileName); setExporting(false); }; + const handleImportChat = async () => { + if (exporting) return; + setExporting(true); + try { + const rawContent = await readFromFile(); // Read the file content using the appropriate function + + const importedData = JSON.parse(rawContent); + // Process the imported chat data and update the chat store + chatStore.newSession(importedData.sessions); + } catch (e) { + showToast(Locale.Settings.Sync.ImportFailed); + console.error(e); + } + setExporting(false); + }; return (