enh: move chat menu
This commit is contained in:
@@ -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);
|
||||
}}
|
||||
|
||||
Reference in New Issue
Block a user