refac
This commit is contained in:
@@ -2632,12 +2632,8 @@
|
|||||||
currentChatPage.set(1);
|
currentChatPage.set(1);
|
||||||
initNewChat();
|
initNewChat();
|
||||||
await goto('/');
|
await goto('/');
|
||||||
getChatList(localStorage.token, $currentChatPage).then((chats) => {
|
chats.set(await getChatList(localStorage.token, $currentChatPage));
|
||||||
chats.set(chats);
|
pinnedChats.set(await getPinnedChatList(localStorage.token));
|
||||||
});
|
|
||||||
getPinnedChatList(localStorage.token).then((pinnedChats) => {
|
|
||||||
pinnedChats.set(pinnedChats);
|
|
||||||
});
|
|
||||||
toast.success($i18n.t('Chat archived.'));
|
toast.success($i18n.t('Chat archived.'));
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error archiving chat:', error);
|
console.error('Error archiving chat:', error);
|
||||||
|
|||||||
@@ -21,6 +21,7 @@
|
|||||||
|
|
||||||
export let show = false;
|
export let show = false;
|
||||||
export let onUpdate = () => {};
|
export let onUpdate = () => {};
|
||||||
|
export let onDelete: (id: string) => void = () => {};
|
||||||
|
|
||||||
let loading = false;
|
let loading = false;
|
||||||
let chatList: any[] | null = null;
|
let chatList: any[] | null = null;
|
||||||
@@ -158,6 +159,9 @@
|
|||||||
onUpdate={() => {
|
onUpdate={() => {
|
||||||
init();
|
init();
|
||||||
}}
|
}}
|
||||||
|
onDelete={(id) => {
|
||||||
|
onDelete(id);
|
||||||
|
}}
|
||||||
loadHandler={loadMoreChats}
|
loadHandler={loadMoreChats}
|
||||||
{unarchiveHandler}
|
{unarchiveHandler}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -50,6 +50,7 @@
|
|||||||
let showDeleteConfirmDialog = false;
|
let showDeleteConfirmDialog = false;
|
||||||
|
|
||||||
export let onUpdate = () => {};
|
export let onUpdate = () => {};
|
||||||
|
export let onDelete: (id: string) => void = () => {};
|
||||||
|
|
||||||
export let loadHandler: null | Function = null;
|
export let loadHandler: null | Function = null;
|
||||||
export let unarchiveHandler: null | Function = null;
|
export let unarchiveHandler: null | Function = null;
|
||||||
@@ -69,6 +70,9 @@
|
|||||||
toast.error(`${error}`);
|
toast.error(`${error}`);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (res) {
|
||||||
|
onDelete(chatId);
|
||||||
|
}
|
||||||
onUpdate();
|
onUpdate();
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -592,6 +592,12 @@
|
|||||||
onUpdate={async () => {
|
onUpdate={async () => {
|
||||||
await initChatList();
|
await initChatList();
|
||||||
}}
|
}}
|
||||||
|
onDelete={(id) => {
|
||||||
|
if ($chatId === id) {
|
||||||
|
chatId.set('');
|
||||||
|
window.history.replaceState({}, '', '/');
|
||||||
|
}
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<ChannelModal
|
<ChannelModal
|
||||||
|
|||||||
@@ -155,6 +155,12 @@
|
|||||||
const archiveChatHandler = async (id) => {
|
const archiveChatHandler = async (id) => {
|
||||||
try {
|
try {
|
||||||
await archiveChatById(localStorage.token, id);
|
await archiveChatById(localStorage.token, id);
|
||||||
|
|
||||||
|
if ($chatId === id) {
|
||||||
|
chatId.set('');
|
||||||
|
window.history.replaceState({}, '', '/');
|
||||||
|
}
|
||||||
|
|
||||||
dispatch('change');
|
dispatch('change');
|
||||||
toast.success($i18n.t('Chat archived.'));
|
toast.success($i18n.t('Chat archived.'));
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
Reference in New Issue
Block a user