diff --git a/src/assets/icons/JsonIcon.tsx b/src/assets/icons/JsonIcon.tsx new file mode 100644 index 0000000..af8e6b5 --- /dev/null +++ b/src/assets/icons/JsonIcon.tsx @@ -0,0 +1,20 @@ +import React from 'react'; + +const JsonIcon = (props: React.SVGProps) => { + return ( + + + + ); +}; + +export default JsonIcon; diff --git a/src/components/Chat/ChatContent/DownloadChat.tsx b/src/components/Chat/ChatContent/DownloadChat.tsx index 64fb4c5..e7da03a 100644 --- a/src/components/Chat/ChatContent/DownloadChat.tsx +++ b/src/components/Chat/ChatContent/DownloadChat.tsx @@ -12,6 +12,9 @@ import { import ImageIcon from '@icon/ImageIcon'; import PdfIcon from '@icon/PdfIcon'; import MarkdownIcon from '@icon/MarkdownIcon'; +import JsonIcon from '@icon/JsonIcon'; + +import downloadFile from '@utils/downloadFile'; const DownloadChat = React.memo( ({ saveRef }: { saveRef: React.RefObject }) => { @@ -101,6 +104,19 @@ const DownloadChat = React.memo( Markdown + )} diff --git a/src/components/ImportExportChat/ImportExportChat.tsx b/src/components/ImportExportChat/ImportExportChat.tsx index cb19cc3..b191822 100644 --- a/src/components/ImportExportChat/ImportExportChat.tsx +++ b/src/components/ImportExportChat/ImportExportChat.tsx @@ -7,6 +7,7 @@ import downloadFile from '@utils/downloadFile'; import { getToday } from '@utils/date'; import PopupModal from '@components/PopupModal'; import { validateAndFixChats } from '@utils/chat'; +import { ChatInterface } from '@type/chat'; const ImportExportChat = () => { const { t } = useTranslation(); @@ -61,7 +62,15 @@ const ImportChat = () => { try { const parsedData = JSON.parse(data); if (validateAndFixChats(parsedData)) { - setChats(parsedData); + const prevChats = useStore.getState().chats; + if (prevChats) { + const updatedChats: ChatInterface[] = JSON.parse( + JSON.stringify(prevChats) + ); + setChats(parsedData.concat(updatedChats)); + } else { + setChats(parsedData); + } setAlert({ message: 'Succesfully imported!', success: true }); } else { setAlert({ message: 'Invalid chats data format', success: false });