enh: move chat menu

This commit is contained in:
Timothy Jaeryang Baek
2025-08-21 04:35:27 +04:00
parent f46837fd10
commit d720e027ad
5 changed files with 160 additions and 31 deletions
@@ -15,7 +15,8 @@
getChatList,
getChatListByTagName,
getPinnedChatList,
updateChatById
updateChatById,
updateChatFolderIdById
} from '$lib/apis/chats';
import {
chatId,
@@ -136,6 +137,29 @@
dispatch('change');
};
const moveChatHandler = async (chatId, folderId) => {
if (chatId && folderId) {
const res = await updateChatFolderIdById(localStorage.token, chatId, folderId).catch(
(error) => {
toast.error(`${error}`);
return null;
}
);
if (res) {
currentChatPage.set(1);
await chats.set(await getChatList(localStorage.token, $currentChatPage));
await pinnedChats.set(await getPinnedChatList(localStorage.token));
dispatch('change');
toast.success($i18n.t('Chat moved successfully'));
}
} else {
toast.error($i18n.t('Failed to move chat'));
}
};
let itemElement;
let generating = false;
@@ -485,6 +509,7 @@
shareHandler={() => {
showShareChatModal = true;
}}
{moveChatHandler}
archiveChatHandler={() => {
archiveChatHandler(id);
}}