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:
@@ -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);
|
||||
}}
|
||||
|
||||
Reference in New Issue
Block a user