fix(chat): support unarchive toggle and dynamic toast in chat header menu (#31473) (#31857)

- Pass `archived` state from active chat model to Navbar context menu
- Render 'Unarchive' instead of 'Archive' when `chat?.archived` is true in Navbar/Menu.svelte
- Dynamically display 'Chat unarchived.' toast upon unarchiving in archiveChatHandler
- Closes #31473

Co-authored-by: PINYO PATTANAWASANPORN <pattanawasanporn@gmail.com>
This commit is contained in:
G30 2026-10-05 03:20:02 -04:00 • committed by GitHub
parent 88720c6928
commit ce94c41d81
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 6 additions and 3 deletions

View file

@ -4209,12 +4209,12 @@
const archiveChatHandler = async (id: string) => {
try {
await archiveChatById(localStorage.token, id);
const res = await archiveChatById(localStorage.token, id);
initNewChat();
await goto('/');
await refreshChatList(localStorage.token, { refreshPinned: true });
await refreshFolderChatLists();
toast.success($i18n.t('Chat archived.'));
toast.success(res?.archived ? $i18n.t('Chat archived.') : $i18n.t('Chat unarchived.'));
} catch (error) {
console.error('Error archiving chat:', error);
toast.error($i18n.t('Failed to archive chat.'));
@ -4422,6 +4422,7 @@
{readOnly}
chat={{
id: $chatId,
archived: chat?.archived ?? false,
chat: {
title: $chatTitle,
models: selectedModels,

View file

@ -484,7 +484,9 @@
}}
>
<ArchiveBox className="size-3.5" strokeWidth="1.5" />
<div class="flex items-center">{$i18n.t('Archive')}</div>
<div class="flex items-center">
{chat?.archived ? $i18n.t('Unarchive') : $i18n.t('Archive')}
</div>
</button>
{#if $user?.role === 'admin' || ($user?.permissions?.chat?.delete ?? true)}