hotfix import

This commit is contained in:
Mckay Wrigley
2023-03-23 19:05:47 -06:00
parent f5118e3037
commit 1f31cc5507
5 changed files with 41 additions and 21 deletions
+9 -4
View File
@@ -1,9 +1,9 @@
import { Conversation } from "@/types";
import { ChatFolder, Conversation } from "@/types";
import { IconFileImport } from "@tabler/icons-react";
import { FC } from "react";
interface Props {
onImport: (conversations: Conversation[]) => void;
onImport: (data: { conversations: Conversation[]; folders: ChatFolder[] }) => void;
}
export const Import: FC<Props> = ({ onImport }) => {
@@ -19,8 +19,13 @@ export const Import: FC<Props> = ({ onImport }) => {
const file = e.target.files[0];
const reader = new FileReader();
reader.onload = (e) => {
const conversations: Conversation[] = JSON.parse(e.target?.result as string);
onImport(conversations);
let json = JSON.parse(e.target?.result as string);
if (!json.folders) {
json = { history: json, folders: [] };
}
onImport({ conversations: json.history, folders: json.folders });
};
reader.readAsText(file);
}}
+1 -1
View File
@@ -25,7 +25,7 @@ interface Props {
onApiKeyChange: (apiKey: string) => void;
onClearConversations: () => void;
onExportConversations: () => void;
onImportConversations: (conversations: Conversation[]) => void;
onImportConversations: (data: { conversations: Conversation[]; folders: ChatFolder[] }) => void;
}
export const Sidebar: FC<Props> = ({ loading, conversations, lightMode, selectedConversation, apiKey, folders, onCreateFolder, onDeleteFolder, onUpdateFolder, onNewConversation, onToggleLightMode, onSelectConversation, onDeleteConversation, onToggleSidebar, onUpdateConversation, onApiKeyChange, onClearConversations, onExportConversations, onImportConversations }) => {
+2 -2
View File
@@ -1,4 +1,4 @@
import { Conversation } from "@/types";
import { ChatFolder, Conversation } from "@/types";
import { IconFileExport, IconMoon, IconSun } from "@tabler/icons-react";
import { FC } from "react";
import { ClearConversations } from "./ClearConversations";
@@ -13,7 +13,7 @@ interface Props {
onApiKeyChange: (apiKey: string) => void;
onClearConversations: () => void;
onExportConversations: () => void;
onImportConversations: (conversations: Conversation[]) => void;
onImportConversations: (data: { conversations: Conversation[]; folders: ChatFolder[] }) => void;
}
export const SidebarSettings: FC<Props> = ({ lightMode, apiKey, onToggleLightMode, onApiKeyChange, onClearConversations, onExportConversations, onImportConversations }) => {