fix import (#242)

* 🐛 fix import (#224)

* 🐛 fix import of corrupted history

see https://github.com/mckaywrigley/chatbot-ui/issues/224#issuecomment-1486080888

* add the run-test-suite github action
This commit is contained in:
Thomas LÉVEIL
2023-03-28 10:27:37 +02:00
committed by GitHub
parent 5aa5be3f43
commit b0c289f7a4
15 changed files with 7061 additions and 55 deletions
+3 -13
View File
@@ -1,16 +1,11 @@
import { Conversation } from '@/types/chat';
import { Folder } from '@/types/folder';
import { cleanConversationHistory } from '@/utils/app/clean';
import { SupportedExportFormats } from '@/types/export';
import { IconFileImport } from '@tabler/icons-react';
import { useTranslation } from 'next-i18next';
import { FC } from 'react';
import { SidebarButton } from '../Sidebar/SidebarButton';
interface Props {
onImport: (data: {
conversations: Conversation[];
folders: Folder[];
}) => void;
onImport: (data: SupportedExportFormats) => void;
}
export const Import: FC<Props> = ({ onImport }) => {
@@ -30,12 +25,7 @@ export const Import: FC<Props> = ({ onImport }) => {
const reader = new FileReader();
reader.onload = (e) => {
let json = JSON.parse(e.target?.result as string);
if (json && !json.folders) {
json = { history: cleanConversationHistory(json), folders: [] };
}
onImport({ conversations: json.history, folders: json.folders });
onImport(json);
};
reader.readAsText(file);
}}