Skip to content

Commit e6931d6

Browse files
refactor(site): Remove optimistic workspace action (#7385)
1 parent dd67283 commit e6931d6

File tree

1 file changed

+4
-25
lines changed

1 file changed

+4
-25
lines changed

site/src/xServices/workspace/workspaceXService.ts

+4-25
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ export const workspaceMachine = createMachine(
385385
},
386386
},
387387
requestingStart: {
388-
entry: ["clearBuildError", "updateStatusToPending"],
388+
entry: ["clearBuildError"],
389389
invoke: {
390390
src: "startWorkspace",
391391
id: "startWorkspace",
@@ -404,7 +404,7 @@ export const workspaceMachine = createMachine(
404404
},
405405
},
406406
requestingStop: {
407-
entry: ["clearBuildError", "updateStatusToPending"],
407+
entry: ["clearBuildError"],
408408
invoke: {
409409
src: "stopWorkspace",
410410
id: "stopWorkspace",
@@ -423,7 +423,7 @@ export const workspaceMachine = createMachine(
423423
},
424424
},
425425
requestingDelete: {
426-
entry: ["clearBuildError", "updateStatusToPending"],
426+
entry: ["clearBuildError"],
427427
invoke: {
428428
src: "deleteWorkspace",
429429
id: "deleteWorkspace",
@@ -442,11 +442,7 @@ export const workspaceMachine = createMachine(
442442
},
443443
},
444444
requestingCancel: {
445-
entry: [
446-
"clearCancellationMessage",
447-
"clearCancellationError",
448-
"updateStatusToPending",
449-
],
445+
entry: ["clearCancellationMessage", "clearCancellationError"],
450446
invoke: {
451447
src: "cancelWorkspace",
452448
id: "cancelWorkspace",
@@ -642,24 +638,7 @@ export const workspaceMachine = createMachine(
642638
)
643639
displayError(message)
644640
},
645-
// Optimistically update. So when the user clicks on stop, we can show
646-
// the "pending" state right away without having to wait 0.5s ~ 2s to
647-
// display the visual feedback to the user.
648-
updateStatusToPending: assign({
649-
workspace: ({ workspace }) => {
650-
if (!workspace) {
651-
throw new Error("Workspace not defined")
652-
}
653641

654-
return {
655-
...workspace,
656-
latest_build: {
657-
...workspace.latest_build,
658-
status: "pending" as TypesGen.WorkspaceStatus,
659-
},
660-
}
661-
},
662-
}),
663642
assignMissedParameters: assign({
664643
missedParameters: (_, { data }) => {
665644
if (!(data instanceof API.MissingBuildParameters)) {

0 commit comments

Comments
 (0)