From 16c9b0e230dca6000a087354333b1eefda41a26c Mon Sep 17 00:00:00 2001 From: Rafi Date: Mon, 3 Apr 2023 23:37:50 +0800 Subject: [PATCH] ... --- layouts/default.vue | 7 ++++--- pages/index.vue | 8 +++++++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/layouts/default.vue b/layouts/default.vue index e56ff2e..b9d3519 100644 --- a/layouts/default.vue +++ b/layouts/default.vue @@ -53,10 +53,11 @@ const deleteConversation = async (index) => { }) deletingConversationIndex.value = null if (!error.value) { - if (conversations.value[index].id === currentConversation.value.id) { - createNewConversation() - } + const deletingConversation = conversations.value[index] conversations.value.splice(index, 1) + if (deletingConversation.id === currentConversation.value.id) { + await navigateTo('/') + } } } diff --git a/pages/index.vue b/pages/index.vue index a088762..9f8d410 100644 --- a/pages/index.vue +++ b/pages/index.vue @@ -22,7 +22,7 @@ const loadMessage = async () => { } } -onActivated(async () => { +onMounted(async () => { if (route.params.id) { conversation.value.loadingMessages = true await loadConversation() @@ -30,7 +30,13 @@ onActivated(async () => { conversation.value.loadingMessages = false } else { conversation.value = getDefaultConversationData() + watch(currentConversation, (val) => { + conversation.value = Object.assign({}, val) + }) } +}) + +onActivated(async () => { currentConversation.value = Object.assign({}, conversation.value) })