From aba2ca39d4e8328310f7179d14fa95f43ee7d279 Mon Sep 17 00:00:00 2001 From: "Timothy J. Baek" Date: Fri, 14 Jun 2024 11:24:15 -0700 Subject: [PATCH] enh: delete confirm dialog --- .../components/common/ConfirmDialog.svelte | 7 +- .../components/layout/Sidebar/ChatItem.svelte | 80 ++++++------------- 2 files changed, 30 insertions(+), 57 deletions(-) diff --git a/src/lib/components/common/ConfirmDialog.svelte b/src/lib/components/common/ConfirmDialog.svelte index 4a243b928..1024ecf39 100644 --- a/src/lib/components/common/ConfirmDialog.svelte +++ b/src/lib/components/common/ConfirmDialog.svelte @@ -9,6 +9,9 @@ export let title = 'Confirm your action'; export let message = 'This action cannot be undone. Do you wish to continue?'; + export let cancelLabel = 'Cancel'; + export let confirmLabel = 'Confirm'; + export let show = false; let modalElement = null; let mounted = false; @@ -70,7 +73,7 @@ }} type="button" > - Cancel + {cancelLabel} diff --git a/src/lib/components/layout/Sidebar/ChatItem.svelte b/src/lib/components/layout/Sidebar/ChatItem.svelte index d79c1ab06..6a5c5b3ba 100644 --- a/src/lib/components/layout/Sidebar/ChatItem.svelte +++ b/src/lib/components/layout/Sidebar/ChatItem.svelte @@ -17,17 +17,17 @@ import ChatMenu from './ChatMenu.svelte'; import ShareChatModal from '$lib/components/chat/ShareChatModal.svelte'; + import DeleteConfirmDialog from '$lib/components/common/ConfirmDialog.svelte'; export let chat; - - let showShareChatModal = false; - export let selected = false; - let confirmEdit = false; - let confirmDelete = false; + let showDeleteConfirmDialog = false; + let showShareChatModal = false; - let chatTitle = ''; + let confirmEdit = false; + + let chatTitle = chat.title; const editChatTitle = async (id, _title) => { if (_title === '') { @@ -43,7 +43,6 @@ const deleteChat = async (id) => { const res = await deleteChatById(localStorage.token, id).catch((error) => { toast.error(error); - confirmDelete = false; return null; }); @@ -80,12 +79,22 @@ + { + deleteChat(chat.id); + }} +> +
+ This will delete {chat.title}. +
+
+