Skip to content

Commit 5fd9047

Browse files
authored
Cleanup dead states in workspace machine
* removed dead build states * removed dead code * removed guards
1 parent 57c84d6 commit 5fd9047

File tree

1 file changed

+0
-55
lines changed

1 file changed

+0
-55
lines changed

site/src/xServices/workspace/workspaceXService.ts

Lines changed: 0 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ export interface WorkspaceContext {
3232
// Builds
3333
builds?: TypesGen.WorkspaceBuild[]
3434
getBuildsError?: Error | unknown
35-
loadMoreBuildsError?: Error | unknown
3635
// error creating a new WorkspaceBuild
3736
buildError?: Error | unknown
3837
cancellationMessage?: Types.Message
@@ -53,7 +52,6 @@ export type WorkspaceEvent =
5352
| { type: "CANCEL_DELETE" }
5453
| { type: "UPDATE" }
5554
| { type: "CANCEL" }
56-
| { type: "LOAD_MORE_BUILDS" }
5755
| { type: "CHECK_REFRESH_TIMELINE"; data: TypesGen.ServerSentEvent["data"] }
5856
| { type: "REFRESH_TIMELINE" }
5957
| { type: "EVENT_SOURCE_ERROR"; error: Error | unknown }
@@ -118,9 +116,6 @@ export const workspaceMachine = createMachine(
118116
getBuilds: {
119117
data: TypesGen.WorkspaceBuild[]
120118
}
121-
loadMoreBuilds: {
122-
data: TypesGen.WorkspaceBuild[]
123-
}
124119
checkPermissions: {
125120
data: TypesGen.UserAuthorizationResponse
126121
}
@@ -396,33 +391,11 @@ export const workspaceMachine = createMachine(
396391
states: {
397392
idle: {
398393
on: {
399-
LOAD_MORE_BUILDS: {
400-
cond: "hasMoreBuilds",
401-
target: "loadingMoreBuilds",
402-
},
403394
REFRESH_TIMELINE: {
404395
target: "#workspaceState.ready.timeline.gettingBuilds",
405396
},
406397
},
407398
},
408-
loadingMoreBuilds: {
409-
entry: "clearLoadMoreBuildsError",
410-
invoke: {
411-
src: "loadMoreBuilds",
412-
onDone: [
413-
{
414-
actions: "assignNewBuilds",
415-
target: "idle",
416-
},
417-
],
418-
onError: [
419-
{
420-
actions: "assignLoadMoreBuildsError",
421-
target: "idle",
422-
},
423-
],
424-
},
425-
},
426399
},
427400
},
428401
},
@@ -530,24 +503,6 @@ export const workspaceMachine = createMachine(
530503
clearGetBuildsError: assign({
531504
getBuildsError: (_) => undefined,
532505
}),
533-
assignNewBuilds: assign({
534-
builds: (context, event) => {
535-
const oldBuilds = context.builds
536-
537-
if (!oldBuilds) {
538-
// This state is theoretically impossible, but helps TS
539-
throw new Error("workspaceXService: failed to load workspace builds")
540-
}
541-
542-
return [...oldBuilds, ...event.data]
543-
},
544-
}),
545-
assignLoadMoreBuildsError: assign({
546-
loadMoreBuildsError: (_, event) => event.data,
547-
}),
548-
clearLoadMoreBuildsError: assign({
549-
loadMoreBuildsError: (_) => undefined,
550-
}),
551506
refreshTimeline: pure((context, event) => {
552507
// No need to refresh the timeline if it is not loaded
553508
if (!context.builds) {
@@ -567,9 +522,6 @@ export const workspaceMachine = createMachine(
567522
}
568523
}),
569524
},
570-
guards: {
571-
hasMoreBuilds: (_) => false,
572-
},
573525
services: {
574526
getWorkspace: async (_, event) => {
575527
return await API.getWorkspaceByOwnerAndName(event.username, event.workspaceName, {
@@ -651,13 +603,6 @@ export const workspaceMachine = createMachine(
651603
throw Error("Cannot get builds without id")
652604
}
653605
},
654-
loadMoreBuilds: async (context) => {
655-
if (context.workspace) {
656-
return await API.getWorkspaceBuilds(context.workspace.id)
657-
} else {
658-
throw Error("Cannot load more builds without id")
659-
}
660-
},
661606
checkPermissions: async (context) => {
662607
if (context.workspace && context.userId) {
663608
return await API.checkUserPermissions(context.userId, {

0 commit comments

Comments
 (0)