fix: ensure the reference is not kept while overwriting requests

This commit is contained in:
jamesgeorge007
2024-02-15 13:04:59 +05:30
parent faa0bf7714
commit b821f452cf
2 changed files with 17 additions and 14 deletions

View File

@@ -1183,6 +1183,7 @@ export function editRESTRequest(
requestIndex: number, requestIndex: number,
requestNew: HoppRESTRequest requestNew: HoppRESTRequest
) { ) {
debugger
const indexPaths = path.split("/").map((x) => parseInt(x)) const indexPaths = path.split("/").map((x) => parseInt(x))
if ( if (
!navigateToFolderWithIndexPath(restCollectionStore.value.state, indexPaths) !navigateToFolderWithIndexPath(restCollectionStore.value.state, indexPaths)

View File

@@ -296,6 +296,20 @@ export class PersonalWorkspaceProviderService
return Promise.resolve(E.left("INVALID_COLLECTION_HANDLE" as const)) return Promise.resolve(E.left("INVALID_COLLECTION_HANDLE" as const))
} }
const { collectionID, providerID, workspaceID } =
parentCollectionHandle.value.data
const insertionIndex = saveRESTRequestAs(collectionID, newRequest)
const requestID = `${collectionID}/${insertionIndex}`
platform.analytics?.logEvent({
type: "HOPP_SAVE_REQUEST",
workspaceType: "personal",
createdNow: true,
platform: "rest",
})
return Promise.resolve( return Promise.resolve(
E.right( E.right(
computed(() => { computed(() => {
@@ -310,20 +324,6 @@ export class PersonalWorkspaceProviderService
} }
} }
const { collectionID, providerID, workspaceID } =
parentCollectionHandle.value.data
const insertionIndex = saveRESTRequestAs(collectionID, newRequest)
platform.analytics?.logEvent({
type: "HOPP_SAVE_REQUEST",
workspaceType: "personal",
createdNow: true,
platform: "rest",
})
const requestID = `${collectionID}/${insertionIndex}`
return { return {
type: "ok", type: "ok",
data: { data: {
@@ -375,6 +375,8 @@ export class PersonalWorkspaceProviderService
return Promise.resolve(E.left("INVALID_REQUEST_HANDLE" as const)) return Promise.resolve(E.left("INVALID_REQUEST_HANDLE" as const))
} }
delete updatedRequest.id
const { collectionID, requestID, request } = requestHandle.value.data const { collectionID, requestID, request } = requestHandle.value.data
const newRequest: HoppRESTRequest = merge(request, updatedRequest) const newRequest: HoppRESTRequest = merge(request, updatedRequest)