refactor: keep tab dirty status logic at the page level

This commit is contained in:
jamesgeorge007
2024-04-25 18:14:22 +05:30
parent cd92dfec47
commit 197d253e8b
5 changed files with 177 additions and 173 deletions

View File

@@ -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<WorkspaceRequest>["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<WorkspaceRequest>["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)
}