fix: affected request indices computation post request move
This commit is contained in:
@@ -712,7 +712,7 @@ export class PersonalWorkspaceProviderService
|
|||||||
|
|
||||||
const draggedRequestIndexPos = this.pathToLastIndex(draggedRequestID)
|
const draggedRequestIndexPos = this.pathToLastIndex(draggedRequestID)
|
||||||
|
|
||||||
const movedRequestHandleIdx = this.issuedHandles.findIndex((handle) => {
|
const movedRequestHandle = this.issuedHandles.find((handle) => {
|
||||||
if (handle.value.type === "invalid") {
|
if (handle.value.type === "invalid") {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -724,8 +724,6 @@ export class PersonalWorkspaceProviderService
|
|||||||
return handle.value.data.requestID === draggedRequestID
|
return handle.value.data.requestID === draggedRequestID
|
||||||
})
|
})
|
||||||
|
|
||||||
const movedRequestHandle = this.issuedHandles[movedRequestHandleIdx]
|
|
||||||
|
|
||||||
if (
|
if (
|
||||||
!movedRequestHandle ||
|
!movedRequestHandle ||
|
||||||
movedRequestHandle.value.type === "invalid" ||
|
movedRequestHandle.value.type === "invalid" ||
|
||||||
@@ -746,8 +744,9 @@ export class PersonalWorkspaceProviderService
|
|||||||
const affectedRequestIDs = Array.from({
|
const affectedRequestIDs = Array.from({
|
||||||
length: affectedReqIndexRange,
|
length: affectedReqIndexRange,
|
||||||
}).map((_, idx) => {
|
}).map((_, idx) => {
|
||||||
const val = affectedReqIndexRange + idx
|
// Affected request indices will start from the next position of the dragged request, hence adding `1`
|
||||||
return `${sourceCollectionID}/${val}`
|
const resolvedRequestIndexPos = draggedRequestIndexPos + idx + 1
|
||||||
|
return `${sourceCollectionID}/${resolvedRequestIndexPos}`
|
||||||
})
|
})
|
||||||
|
|
||||||
moveRESTRequest(
|
moveRESTRequest(
|
||||||
@@ -761,18 +760,13 @@ export class PersonalWorkspaceProviderService
|
|||||||
destinationCollectionID
|
destinationCollectionID
|
||||||
).length
|
).length
|
||||||
|
|
||||||
// @ts-expect-error - Updating handle data the moved request
|
movedRequestHandle.value.data.collectionID = destinationCollectionID
|
||||||
this.issuedHandles[movedRequestHandleIdx].value.data = {
|
movedRequestHandle.value.data.requestID = `${destinationCollectionID}/${
|
||||||
// @ts-expect-error - Updating the IDs
|
destinationCollectionReqCount - 1
|
||||||
...this.issuedHandles[movedRequestHandleIdx].value.data,
|
}`
|
||||||
collectionID: destinationCollectionID,
|
|
||||||
requestID: `${destinationCollectionID}/${
|
|
||||||
destinationCollectionReqCount - 1
|
|
||||||
}`,
|
|
||||||
}
|
|
||||||
|
|
||||||
affectedRequestIDs.forEach((requestID) => {
|
affectedRequestIDs.forEach((requestID) => {
|
||||||
const handleIdx = this.issuedHandles.findIndex((handle) => {
|
const handle = this.issuedHandles.find((handle) => {
|
||||||
if (handle.value.type === "invalid") {
|
if (handle.value.type === "invalid") {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -784,8 +778,6 @@ export class PersonalWorkspaceProviderService
|
|||||||
return handle.value.data.requestID === requestID
|
return handle.value.data.requestID === requestID
|
||||||
})
|
})
|
||||||
|
|
||||||
const handle = this.issuedHandles[handleIdx]
|
|
||||||
|
|
||||||
if (
|
if (
|
||||||
!handle ||
|
!handle ||
|
||||||
handle.value.type === "invalid" ||
|
handle.value.type === "invalid" ||
|
||||||
|
|||||||
Reference in New Issue
Block a user