From 5af24b3ebe1587ef87792cba772d03e923d4f070 Mon Sep 17 00:00:00 2001 From: Shirasawa <764798966@qq.com> Date: Thu, 5 Mar 2026 03:54:21 +0800 Subject: [PATCH] fix: Implement archive chat handler in Chat page navbar (#22229) --- src/lib/components/chat/Chat.svelte | 22 ++++++++++++++++++- .../components/layout/Sidebar/ChatItem.svelte | 10 +++++++-- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/src/lib/components/chat/Chat.svelte b/src/lib/components/chat/Chat.svelte index d3d216cf4..50b9a0294 100644 --- a/src/lib/components/chat/Chat.svelte +++ b/src/lib/components/chat/Chat.svelte @@ -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.')); + } + }; @@ -2667,7 +2687,7 @@ bind:selectedModels shareEnabled={!!history.currentId} {initNewChat} - archiveChatHandler={() => {}} + {archiveChatHandler} {moveChatHandler} onSaveTempChat={async () => { try { diff --git a/src/lib/components/layout/Sidebar/ChatItem.svelte b/src/lib/components/layout/Sidebar/ChatItem.svelte index 3a4f16e79..7134b1e94 100644 --- a/src/lib/components/layout/Sidebar/ChatItem.svelte +++ b/src/lib/components/layout/Sidebar/ChatItem.svelte @@ -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) => {