diff --git a/src/components/ImportExportChat/ImportExportChat.tsx b/src/components/ImportExportChat/ImportExportChat.tsx index b191822..b75b541 100644 --- a/src/components/ImportExportChat/ImportExportChat.tsx +++ b/src/components/ImportExportChat/ImportExportChat.tsx @@ -43,6 +43,8 @@ const ImportExportChat = () => { const ImportChat = () => { const { t } = useTranslation(); const setChats = useStore.getState().setChats; + const setFoldersName = useStore.getState().setFoldersName; + const setFoldersExpanded = useStore.getState().setFoldersExpanded; const inputRef = useRef(null); const [alert, setAlert] = useState<{ message: string; @@ -62,6 +64,20 @@ const ImportChat = () => { try { const parsedData = JSON.parse(data); if (validateAndFixChats(parsedData)) { + const parsedFolders: string[] = []; + parsedData.forEach((data) => { + if (data.folder && !parsedFolders.includes(data.folder)) + parsedFolders.push(data.folder); + }); + setFoldersName([ + ...parsedFolders, + ...useStore.getState().foldersName, + ]); + setFoldersExpanded([ + ...new Array(parsedFolders.length).fill(false), + ...useStore.getState().foldersExpanded, + ]); + const prevChats = useStore.getState().chats; if (prevChats) { const updatedChats: ChatInterface[] = JSON.parse( diff --git a/src/components/Menu/MenuOptions/ClearConversation.tsx b/src/components/Menu/MenuOptions/ClearConversation.tsx index 6c1cc8d..c63835f 100644 --- a/src/components/Menu/MenuOptions/ClearConversation.tsx +++ b/src/components/Menu/MenuOptions/ClearConversation.tsx @@ -1,5 +1,6 @@ import React, { useState } from 'react'; import { useTranslation } from 'react-i18next'; +import useStore from '@store/store'; import PopupModal from '@components/PopupModal'; import DeleteIcon from '@icon/DeleteIcon'; @@ -9,10 +10,14 @@ const ClearConversation = () => { const { t } = useTranslation(); const initialiseNewChat = useInitialiseNewChat(); + const setFoldersName = useStore((state) => state.setFoldersName); + const setFoldersExpanded = useStore((state) => state.setFoldersExpanded); const [isModalOpen, setIsModalOpen] = useState(false); const handleConfirm = () => { setIsModalOpen(false); + setFoldersName([]); + setFoldersExpanded([]); initialiseNewChat(); };