fix: Implement archive chat handler in Chat page navbar (#22229)
This commit is contained in:
@@ -65,6 +65,7 @@
|
|||||||
import { AudioQueue } from '$lib/utils/audio';
|
import { AudioQueue } from '$lib/utils/audio';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
archiveChatById,
|
||||||
createNewChat,
|
createNewChat,
|
||||||
getAllTags,
|
getAllTags,
|
||||||
getChatById,
|
getChatById,
|
||||||
@@ -2585,6 +2586,25 @@
|
|||||||
toast.error($i18n.t('Failed to move chat'));
|
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>
|
</script>
|
||||||
|
|
||||||
<svelte:head>
|
<svelte:head>
|
||||||
@@ -2667,7 +2687,7 @@
|
|||||||
bind:selectedModels
|
bind:selectedModels
|
||||||
shareEnabled={!!history.currentId}
|
shareEnabled={!!history.currentId}
|
||||||
{initNewChat}
|
{initNewChat}
|
||||||
archiveChatHandler={() => {}}
|
{archiveChatHandler}
|
||||||
{moveChatHandler}
|
{moveChatHandler}
|
||||||
onSaveTempChat={async () => {
|
onSaveTempChat={async () => {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -154,8 +154,14 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
const archiveChatHandler = async (id) => {
|
const archiveChatHandler = async (id) => {
|
||||||
await archiveChatById(localStorage.token, id);
|
try {
|
||||||
dispatch('change');
|
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) => {
|
const moveChatHandler = async (chatId, folderId) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user