This commit is contained in:
Timothy Jaeryang Baek
2026-09-19 17:45:05 -04:00
parent 65a3a115eb
commit 8b3ee28272
3 changed files with 21 additions and 10 deletions
@@ -20,7 +20,7 @@
unarchiveAllChats
} from '$lib/apis/chats';
import { chatId, showSettings, user } from '$lib/stores';
import { refreshChatList } from '$lib/stores/chatList';
import { refreshChatList, refreshSidebar } from '$lib/stores/chatList';
import { formatNumber } from '$lib/utils';
import ConfirmDialog from '$lib/components/common/ConfirmDialog.svelte';
import Dropdown from '$lib/components/common/Dropdown.svelte';
@@ -124,7 +124,7 @@
chatList = chatList?.filter((chat) => chat.id !== id) ?? null;
if (chatCount !== null) chatCount -= 1;
await refreshChatList(localStorage.token);
await refreshChatList(localStorage.token, { refreshPinned: true });
};
const deleteHandler = async () => {
@@ -150,10 +150,11 @@
const unarchiveAllHandler = async () => {
loading = true;
try {
await unarchiveAllChats(localStorage.token);
const success = await unarchiveAllChats(localStorage.token);
if (!success) return;
toast.success($i18n.t('All chats have been unarchived.'));
await loadChats();
await refreshChatList(localStorage.token);
await refreshSidebar(localStorage.token);
} catch (error) {
toast.error(`${error}`);
} finally {
@@ -4,7 +4,7 @@
const { saveAs } = fileSaver;
import { user } from '$lib/stores';
import { refreshChatList } from '$lib/stores/chatList';
import { refreshSidebar } from '$lib/stores/chatList';
import { archiveAllChats, deleteAllChats, getAllChats, importChats } from '$lib/apis/chats';
import { getImportOrigin, convertOpenAIChats } from '$lib/utils';
@@ -87,7 +87,7 @@
toast.success(`Successfully imported ${res.length} chats.`);
}
await refreshChatList(localStorage.token, { refreshPinned: true });
await refreshSidebar(localStorage.token);
};
const exportChats = async () => {
@@ -99,20 +99,22 @@
const archiveAllChatsHandler = async () => {
await goto('/');
await archiveAllChats(localStorage.token).catch((error) => {
const success = await archiveAllChats(localStorage.token).catch((error) => {
toast.error(`${error}`);
});
if (!success) return;
await refreshChatList(localStorage.token, { clearPinned: true });
await refreshSidebar(localStorage.token);
};
const deleteAllChatsHandler = async () => {
await goto('/');
await deleteAllChats(localStorage.token).catch((error) => {
const success = await deleteAllChats(localStorage.token).catch((error) => {
toast.error(`${error}`);
});
if (!success) return;
await refreshChatList(localStorage.token);
await refreshSidebar(localStorage.token);
};
</script>
+8
View File
@@ -79,6 +79,14 @@ export const refreshFolderChatLists = async (
await Promise.all([...folderRefreshHandlers].map((handler) => handler(folderId, chat)));
};
export const refreshSidebar = async (token: string = '') => {
await Promise.all([
refreshChatList(token, { refreshPinned: true }),
refreshFolderChatLists(null),
refreshFolderChatLists()
]);
};
export const loadNextChatListPage = async (token: string = ''): Promise<ChatListResult> => {
if (!paginationReady || allLoaded || loadingNextPage) {
return { accepted: false, allLoaded };