This commit is contained in:
Timothy Jaeryang Baek 2024-11-10 16:39:11 -08:00
parent 6ed085b90b
commit f7b98e8c84

View File

@ -7,24 +7,24 @@
const dispatch = createEventDispatcher(); const dispatch = createEventDispatcher();
import Modal from '$lib/components/common/Modal.svelte';
import { import {
archiveChatById, archiveChatById,
deleteChatById, deleteChatById,
getAllArchivedChats, getAllArchivedChats,
getArchivedChatList getArchivedChatList
} from '$lib/apis/chats'; } from '$lib/apis/chats';
import Modal from '$lib/components/common/Modal.svelte';
import Tooltip from '$lib/components/common/Tooltip.svelte'; import Tooltip from '$lib/components/common/Tooltip.svelte';
import ConfirmDialog from '$lib/components/common/ConfirmDialog.svelte'; import UnarchiveAllConfirmDialog from '$lib/components/common/ConfirmDialog.svelte';
const i18n = getContext('i18n'); const i18n = getContext('i18n');
export let show = false; export let show = false;
let searchValue = '';
let chats = []; let chats = [];
let unarchiveAllDialogShow = false; let searchValue = '';
let showUnarchiveAllConfirmDialog = false;
const unarchiveChatHandler = async (chatId) => { const unarchiveChatHandler = async (chatId) => {
const res = await archiveChatById(localStorage.token, chatId).catch((error) => { const res = await archiveChatById(localStorage.token, chatId).catch((error) => {
@ -65,6 +65,15 @@
} }
</script> </script>
<UnarchiveAllConfirmDialog
bind:show={showUnarchiveAllConfirmDialog}
message={$i18n.t('Are you sure you want to unarchive all archived chats?')}
confirmLabel={$i18n.t('Unarchive All')}
on:confirm={() => {
unarchiveAllHandler();
}}
/>
<Modal size="lg" bind:show> <Modal size="lg" bind:show>
<div> <div>
<div class=" flex justify-between dark:text-gray-300 px-5 pt-4 pb-1"> <div class=" flex justify-between dark:text-gray-300 px-5 pt-4 pb-1">
@ -212,25 +221,16 @@
</div> </div>
</div> </div>
<div class="flex flex-wrap text-sm font-medium gap-1.5 mt-2 m-1"> <div class="flex flex-wrap text-sm font-medium gap-1.5 mt-2 m-1 justify-end w-full">
<button <button
class=" px-3.5 py-1.5 font-medium hover:bg-black/5 dark:hover:bg-white/5 outline outline-1 outline-gray-300 dark:outline-gray-800 rounded-3xl" class=" px-3.5 py-1.5 font-medium hover:bg-black/5 dark:hover:bg-white/5 outline outline-1 outline-gray-300 dark:outline-gray-800 rounded-3xl"
on:click={() => { on:click={() => {
unarchiveAllDialogShow = true; showUnarchiveAllConfirmDialog = true;
}} }}
> >
{$i18n.t('Unarchive All Archived Chats')} {$i18n.t('Unarchive All Archived Chats')}
</button> </button>
<ConfirmDialog
bind:show={unarchiveAllDialogShow}
message={$i18n.t('Are you sure you want to unarchive all archived chats?')}
confirmLabel={$i18n.t('Unarchive All')}
on:confirm={() => {
unarchiveAllHandler();
}}
/>
<button <button
class="px-3.5 py-1.5 font-medium hover:bg-black/5 dark:hover:bg-white/5 outline outline-1 outline-gray-300 dark:outline-gray-800 rounded-3xl" class="px-3.5 py-1.5 font-medium hover:bg-black/5 dark:hover:bg-white/5 outline outline-1 outline-gray-300 dark:outline-gray-800 rounded-3xl"
on:click={() => { on:click={() => {