fix(client): persist workspace drag order

This commit is contained in:
_Kerman
2026-08-11 15:57:43 +08:00
parent 31768a348e
commit 2ad471123d
4 changed files with 84 additions and 21 deletions

View File

@@ -173,10 +173,19 @@ export class WorkspaceManager {
const frameGeneration = this.orderFrameGeneration
const previousOrder = this.itemViews().map(workspace => workspace.workspaceId)
this.installOrder(insertIdBefore(previousOrder, workspaceId, beforeWorkspaceId))
const { result } = await this.api.workspace.insertBefore({
workspaceId,
...beforeWorkspaceId === undefined ? {} : { beforeWorkspaceId },
})
let result: RpcResult<{ workspaceIds: WorkspaceId[] }>
try {
;({ result } = await this.api.workspace.insertBefore({
workspaceId,
...beforeWorkspaceId === undefined ? {} : { beforeWorkspaceId },
}))
} catch (error) {
if (requestGeneration === this.orderRequestGeneration
&& frameGeneration === this.orderFrameGeneration) {
this.installOrder(previousOrder)
}
throw error
}
if (result.ok && requestGeneration === this.orderRequestGeneration
&& frameGeneration === this.orderFrameGeneration) {
this.installOrder(result.value.workspaceIds)