refactor: persist IDs under tab save context

This commit is contained in:
jamesgeorge007
2024-02-16 19:09:06 +05:30
parent 89f7c2ce5e
commit 316dc8f759
9 changed files with 110 additions and 182 deletions

View File

@@ -495,8 +495,10 @@ const HoppRESTSaveContextSchema = z.nullable(
z
.object({
originLocation: z.literal("workspace-user-collection"),
// TODO: Specify the correct shape
requestHandle: z.any(),
workspaceID: z.string(),
providerID: z.string(),
collectionID: z.string(),
requestID: z.string(),
})
.strict(),
z

View File

@@ -1,5 +1,5 @@
import { isEqual } from "lodash-es"
import { computed, ref } from "vue"
import { computed } from "vue"
import { getDefaultRESTRequest } from "~/helpers/rest/default"
import { HoppRESTDocument, HoppRESTSaveContext } from "~/helpers/rest/document"
import { TabService } from "./tab"
@@ -58,24 +58,9 @@ export class RESTTabService extends TabService<HoppRESTDocument> {
ctx?.originLocation === "workspace-user-collection" &&
tab.document.saveContext?.originLocation === "workspace-user-collection"
) {
const tabDocumentRequestHandle = ref(
tab.document.saveContext?.requestHandle
)
if (
ctx?.requestHandle.value?.type === "invalid" ||
tabDocumentRequestHandle?.value.type === "invalid"
) {
return
}
if (
isEqual(
ctx?.requestHandle.value.data.request.id,
tabDocumentRequestHandle.value.data.request.id
)
)
if (isEqual(ctx, tab.document.saveContext)) {
return this.getTabRef(tab.id)
}
}
}