fix: Implement archive chat handler in Chat page navbar (#22229)

This commit is contained in:
Shirasawa
2026-03-04 13:54:21 -06:00
committed by GitHub
parent a36692b4a2
commit 5af24b3ebe
2 changed files with 29 additions and 3 deletions
+21 -1
View File
@@ -65,6 +65,7 @@
import { AudioQueue } from '$lib/utils/audio';
import {
archiveChatById,
createNewChat,
getAllTags,
getChatById,
@@ -2585,6 +2586,25 @@
toast.error($i18n.t('Failed to move chat'));
}
};
const archiveChatHandler = async (id: string) => {
try {
await archiveChatById(localStorage.token, id);
currentChatPage.set(1);
initNewChat();
await goto('/');
getChatList(localStorage.token, $currentChatPage).then((chats) => {
chats.set(chats);
});
getPinnedChatList(localStorage.token).then((pinnedChats) => {
pinnedChats.set(pinnedChats);
});
toast.success($i18n.t('Chat archived.'));
} catch (error) {
console.error('Error archiving chat:', error);
toast.error($i18n.t('Failed to archive chat.'));
}
};
</script>
<svelte:head>
@@ -2667,7 +2687,7 @@
bind:selectedModels
shareEnabled={!!history.currentId}
{initNewChat}
archiveChatHandler={() => {}}
{archiveChatHandler}
{moveChatHandler}
onSaveTempChat={async () => {
try {
@@ -154,8 +154,14 @@
};
const archiveChatHandler = async (id) => {
await archiveChatById(localStorage.token, id);
dispatch('change');
try {
await archiveChatById(localStorage.token, id);
dispatch('change');
toast.success($i18n.t('Chat archived.'));
} catch (error) {
console.error('Error archiving chat:', error);
toast.error($i18n.t('Failed to archive chat.'));
}
};
const moveChatHandler = async (chatId, folderId) => {