From 197d253e8b5a27d992dffb3aef32cf65fb0c7e75 Mon Sep 17 00:00:00 2001 From: jamesgeorge007 Date: Thu, 25 Apr 2024 18:14:22 +0530 Subject: [PATCH] refactor: keep tab dirty status logic at the page level --- .../components/new-collections/rest/index.vue | 43 ---- .../hoppscotch-common/src/pages/index.vue | 215 +++++++++++++----- .../providers/personal.workspace.ts | 27 ++- .../src/services/tab/rest.ts | 3 +- .../hoppscotch-common/src/services/tab/tab.ts | 62 +---- 5 files changed, 177 insertions(+), 173 deletions(-) diff --git a/packages/hoppscotch-common/src/components/new-collections/rest/index.vue b/packages/hoppscotch-common/src/components/new-collections/rest/index.vue index 700cb8b1d..694cbf192 100644 --- a/packages/hoppscotch-common/src/components/new-collections/rest/index.vue +++ b/packages/hoppscotch-common/src/components/new-collections/rest/index.vue @@ -772,27 +772,6 @@ const onRemoveRootCollection = async () => { return } - const activeTabs = tabs.getActiveTabs() - - for (const tab of activeTabs.value) { - if ( - tab.document.saveContext?.originLocation === "workspace-user-collection" - ) { - const requestHandle = tab.document.saveContext?.requestHandle as - | HandleRef["value"] - | undefined - - if (requestHandle?.type === "invalid") { - continue - } - - if (requestHandle!.data.requestID.startsWith(collectionIndexPath)) { - tab.document.saveContext = null - tab.document.isDirty = true - } - } - } - toast.success(t("state.deleted")) displayConfirmModal(false) } @@ -1062,28 +1041,6 @@ const onRemoveChildCollection = async () => { return } - // TODO: Tab holding a request under the collection should be aware of the parent collection invalidation and toggle the dirty state - const activeTabs = tabs.getActiveTabs() - - for (const tab of activeTabs.value) { - if ( - tab.document.saveContext?.originLocation === "workspace-user-collection" - ) { - const requestHandle = tab.document.saveContext?.requestHandle as - | HandleRef["value"] - | undefined - - if (requestHandle?.type === "invalid") { - continue - } - - if (requestHandle!.data.requestID.startsWith(parentCollectionIndexPath)) { - tab.document.saveContext = null - tab.document.isDirty = true - } - } - } - toast.success(t("state.deleted")) displayConfirmModal(false) } diff --git a/packages/hoppscotch-common/src/pages/index.vue b/packages/hoppscotch-common/src/pages/index.vue index 01dcfa86c..f8a4503a4 100644 --- a/packages/hoppscotch-common/src/pages/index.vue +++ b/packages/hoppscotch-common/src/pages/index.vue @@ -13,7 +13,7 @@