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}. +
+
+
{#if confirmEdit} {:else}
{ + chatTitle = chat.title; + confirmEdit = true; }} deleteHandler={() => { - confirmDelete = true; + showDeleteConfirmDialog = true; }} onClose={() => { selected = false; @@ -277,7 +247,7 @@ id="delete-chat-button" class="hidden" on:click={() => { - confirmDelete = true; + showDeleteConfirmDialog = true; }} >