diff --git a/src/lib/components/layout/Sidebar/ArchivedChatsModal.svelte b/src/lib/components/layout/Sidebar/ArchivedChatsModal.svelte index b2ae11058..260c99cf8 100644 --- a/src/lib/components/layout/Sidebar/ArchivedChatsModal.svelte +++ b/src/lib/components/layout/Sidebar/ArchivedChatsModal.svelte @@ -7,22 +7,25 @@ const dispatch = createEventDispatcher(); - import Modal from '$lib/components/common/Modal.svelte'; import { archiveChatById, deleteChatById, getAllArchivedChats, getArchivedChatList } from '$lib/apis/chats'; + + import Modal from '$lib/components/common/Modal.svelte'; import Tooltip from '$lib/components/common/Tooltip.svelte'; + import UnarchiveAllConfirmDialog from '$lib/components/common/ConfirmDialog.svelte'; const i18n = getContext('i18n'); export let show = false; - let searchValue = ''; - let chats = []; + let searchValue = ''; + let showUnarchiveAllConfirmDialog = false; + const unarchiveChatHandler = async (chatId) => { const res = await archiveChatById(localStorage.token, chatId).catch((error) => { toast.error(error); @@ -45,7 +48,14 @@ let blob = new Blob([JSON.stringify(chats)], { type: 'application/json' }); - saveAs(blob, `archived-chat-export-${Date.now()}.json`); + saveAs(blob, `${$i18n.t('archived-chat-export')}-${Date.now()}.json`); + }; + + const unarchiveAllHandler = async () => { + for (const chat of chats) { + await archiveChatById(localStorage.token, chat.id); + } + chats = await getArchivedChatList(localStorage.token); }; $: if (show) { @@ -55,6 +65,15 @@ } + { + unarchiveAllHandler(); + }} +/> +
@@ -72,7 +91,9 @@ class="w-5 h-5" > @@ -144,7 +165,7 @@
- + - +
-
+
+ {$i18n.t('Unarchive All Archived Chats')} + + +
{:else}