diff --git a/src/lib/components/chat/Settings/Personalization/ManageModal.svelte b/src/lib/components/chat/Settings/Personalization/ManageModal.svelte index ac9f36a90..b55261c17 100644 --- a/src/lib/components/chat/Settings/Personalization/ManageModal.svelte +++ b/src/lib/components/chat/Settings/Personalization/ManageModal.svelte @@ -12,6 +12,7 @@ import { error } from '@sveltejs/kit'; import EditMemoryModal from './EditMemoryModal.svelte'; import localizedFormat from 'dayjs/plugin/localizedFormat'; + import ConfirmDialog from '$lib/components/common/ConfirmDialog.svelte'; const i18n = getContext('i18n'); dayjs.extend(localizedFormat); @@ -26,6 +27,21 @@ let selectedMemory = null; + let showClearConfirmDialog = false; + + let onClearConfirmed = async () => { + const res = await deleteMemoriesByUserId(localStorage.token).catch((error) => { + toast.error(`${error}`); + return null; + }); + + if (res && memories.length > 0) { + toast.success($i18n.t('Memory cleared successfully')); + memories = []; + } + showClearConfirmDialog = false; + }; + $: if (show && memories.length === 0 && loading) { (async () => { memories = await getMemories(localStorage.token); @@ -175,15 +191,11 @@ > @@ -192,6 +204,16 @@ + { + showClearConfirmDialog = false; + }} +/> + {