fix: keep folders expanded

This commit is contained in:
Jing Hua 2023-03-27 23:07:32 +08:00
parent a0c43a4ac0
commit cb9f6fb3db
2 changed files with 11 additions and 3 deletions

View file

@ -59,9 +59,15 @@ const ChatFolder = ({
}); });
setChats(updatedChats); setChats(updatedChats);
setFoldersName( const updatedFoldersName = [...useStore.getState().foldersName];
useStore.getState().foldersName.filter((name) => name !== folderName) const updatedFoldersExpanded = [...useStore.getState().foldersExpanded];
);
const i = updatedFoldersName.findIndex((name) => name === folderName);
updatedFoldersName.splice(i, 1);
updatedFoldersExpanded.splice(i, 1);
setFoldersName(updatedFoldersName);
setFoldersExpanded(updatedFoldersExpanded);
setIsDelete(false); setIsDelete(false);
}; };

View file

@ -8,6 +8,7 @@ const NewFolder = () => {
const { t } = useTranslation(); const { t } = useTranslation();
const generating = useStore((state) => state.generating); const generating = useStore((state) => state.generating);
const setFoldersName = useStore((state) => state.setFoldersName); const setFoldersName = useStore((state) => state.setFoldersName);
const setFoldersExpanded = useStore((state) => state.setFoldersExpanded);
const addFolder = () => { const addFolder = () => {
let folderIndex = 1; let folderIndex = 1;
@ -23,6 +24,7 @@ const NewFolder = () => {
} }
setFoldersName([name, ...useStore.getState().foldersName]); setFoldersName([name, ...useStore.getState().foldersName]);
setFoldersExpanded([false, ...useStore.getState().foldersExpanded]);
}; };
return ( return (