diff --git a/src/lib/components/layout/Sidebar/ChatItem.svelte b/src/lib/components/layout/Sidebar/ChatItem.svelte index 26b76ce60..6bb37981a 100644 --- a/src/lib/components/layout/Sidebar/ChatItem.svelte +++ b/src/lib/components/layout/Sidebar/ChatItem.svelte @@ -140,7 +140,12 @@ } }; + let deleting = false; + const deleteChatHandler = async (id) => { + if (deleting) return; + deleting = true; + const res = await deleteChatById(localStorage.token, id).catch((error) => { toast.error(`${error}`); return null; @@ -157,9 +162,16 @@ dispatch('change'); } + + deleting = false; }; + let archiving = false; + const archiveChatHandler = async (id) => { + if (archiving) return; + archiving = true; + try { await archiveChatById(localStorage.token, id); @@ -173,6 +185,8 @@ } catch (error) { console.error('Error archiving chat:', error); toast.error($i18n.t('Failed to archive chat.')); + } finally { + archiving = false; } }; @@ -537,7 +551,8 @@