This commit is contained in:
Timothy Jaeryang Baek committed 2026-04-01 05:41:26 -05:00
1 parent 0f8d7982e1
commit 61558d59c3
1 file changed
+18 -2
@@ -140,7 +140,12 @@
} }
}; };
let deleting = false;
const deleteChatHandler = async (id) => { const deleteChatHandler = async (id) => {
if (deleting) return;
deleting = true;
const res = await deleteChatById(localStorage.token, id).catch((error) => { const res = await deleteChatById(localStorage.token, id).catch((error) => {
toast.error(`${error}`); toast.error(`${error}`);
return null; return null;
@@ -157,9 +162,16 @@
dispatch('change'); dispatch('change');
} }
deleting = false;
}; };
let archiving = false;
const archiveChatHandler = async (id) => { const archiveChatHandler = async (id) => {
if (archiving) return;
archiving = true;
try { try {
await archiveChatById(localStorage.token, id); await archiveChatById(localStorage.token, id);
@@ -173,6 +185,8 @@
} catch (error) { } catch (error) {
console.error('Error archiving chat:', error); console.error('Error archiving chat:', error);
toast.error($i18n.t('Failed to archive chat.')); toast.error($i18n.t('Failed to archive chat.'));
} finally {
archiving = false;
} }
}; };
@@ -537,7 +551,8 @@
<div class=" flex items-center self-center space-x-1.5"> <div class=" flex items-center self-center space-x-1.5">
<Tooltip content={$i18n.t('Archive')} className="flex items-center"> <Tooltip content={$i18n.t('Archive')} className="flex items-center">
<button <button
class=" self-center dark:hover:text-white transition" class=" self-center dark:hover:text-white transition disabled:cursor-not-allowed"
disabled={archiving}
on:click={() => { on:click={() => {
archiveChatHandler(id); archiveChatHandler(id);
}} }}
@@ -549,7 +564,8 @@
<Tooltip content={$i18n.t('Delete')}> <Tooltip content={$i18n.t('Delete')}>
<button <button
class=" self-center dark:hover:text-white transition" class=" self-center dark:hover:text-white transition disabled:cursor-not-allowed"
disabled={deleting}
on:click={() => { on:click={() => {
deleteChatHandler(id); deleteChatHandler(id);
}} }}