refactor: signify updates via handle reference mutation post request move action

This commit is contained in:
jamesgeorge007
2024-04-29 13:36:46 +05:30
parent e5e1260632
commit 6cde6200ae
2 changed files with 29 additions and 30 deletions

View File

@@ -1701,44 +1701,19 @@ const dropRequest = async (payload: {
const { auth, headers } = cascadingAuthHeadersHandle.value.data
const { providerID, workspaceID } = requestHandle.value.data
const possibleTab = tabs.getTabRefWithSaveContext({
originLocation: "workspace-user-collection",
requestHandle,
})
// If there is a tab attached to this request, update its save context
// If there is a tab attached to this request, update the document `inheritedProperties`
if (possibleTab) {
const newRequestID = `${destinationCollectionIndex}/${(
getRequestsByPath(restCollectionState.value, destinationCollectionIndex)
.length - 1
).toString()}`
possibleTab.value.document.saveContext = {
originLocation: "workspace-user-collection",
workspaceID,
providerID,
requestID: newRequestID,
}
possibleTab.value.document.inheritedProperties = {
auth,
headers,
}
}
// When it's drop it's basically getting deleted from last folder. reordering last folder accordingly
resolveSaveContextOnRequestReorder({
lastIndex: pathToLastIndex(requestIndex),
newIndex: -1, // being deleted from last folder
folderPath: parentCollectionIndexPath,
length: getRequestsByPath(
restCollectionState.value,
parentCollectionIndexPath
).length,
})
toast.success(`${t("request.moved")}`)
draggingToRoot.value = false
}