Skip to content

Commit 249dc58

Browse files
committed
continue progress
Signed-off-by: shmck <[email protected]>
1 parent 64c3e7a commit 249dc58

File tree

7 files changed

+22
-15
lines changed

7 files changed

+22
-15
lines changed

src/channel/index.ts

+6-5
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,9 @@ class Channel implements Channel {
185185
config: continueConfig,
186186
alreadyConfigured: true,
187187
})
188+
logger('check stepId on EDITOR_TUTORIAL_CONTINUE_CONFIG', action.payload.stepId)
188189
// update the current stepId on startup
189-
vscode.commands.executeCommand(COMMANDS.SET_CURRENT_STEP, action.payload)
190+
vscode.commands.executeCommand(COMMANDS.SET_CURRENT_STEP, action.payload.stepId)
190191
return
191192
case 'EDITOR_VALIDATE_SETUP':
192193
// check workspace is selected
@@ -233,14 +234,14 @@ class Channel implements Channel {
233234
return
234235
// load step actions (git commits, commands, open files)
235236
case 'SETUP_ACTIONS':
236-
await vscode.commands.executeCommand(COMMANDS.SET_CURRENT_STEP, action.payload)
237-
setupActions(action.payload, this.send)
237+
await vscode.commands.executeCommand(COMMANDS.SET_CURRENT_STEP, action.payload.stepId)
238+
setupActions(action.payload.actions, this.send)
238239
return
239240
// load solution step actions (git commits, commands, open files)
240241
case 'SOLUTION_ACTIONS':
241-
await solutionActions(action.payload, this.send)
242+
await solutionActions(action.payload.actions, this.send)
242243
// run test following solution to update position
243-
vscode.commands.executeCommand(COMMANDS.RUN_TEST, action.payload)
244+
vscode.commands.executeCommand(COMMANDS.RUN_TEST, action.payload.stepId)
244245
return
245246

246247
default:

src/editor/commands.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ interface CreateCommandProps {
1919
export const createCommands = ({ extensionPath, workspaceState }: CreateCommandProps) => {
2020
// React panel webview
2121
let webview: any
22-
let currentStepId = ''
22+
let currentStepId: string | null = ''
2323
let testRunner: any
2424

2525
return {
@@ -67,13 +67,13 @@ export const createCommands = ({ extensionPath, workspaceState }: CreateCommandP
6767
},
6868
})
6969
},
70-
[COMMANDS.SET_CURRENT_STEP]: ({ stepId }: Payload) => {
70+
[COMMANDS.SET_CURRENT_STEP]: (stepId: string | null) => {
7171
// set from last setup stepAction
7272
currentStepId = stepId
7373
},
74-
[COMMANDS.RUN_TEST]: (current: Payload | undefined, onSuccess: () => void) => {
74+
[COMMANDS.RUN_TEST]: (stepId: string | null | undefined, onSuccess: () => void) => {
7575
// use stepId from client, or last set stepId
76-
const payload: Payload = { stepId: current && current.stepId.length ? current.stepId : currentStepId }
76+
const payload: Payload = { stepId: stepId ?? null }
7777
testRunner(payload, onSuccess)
7878
},
7979
}

src/services/testRunner/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { clearOutput, displayOutput } from './output'
77
import { formatFailOutput } from './formatOutput'
88

99
export interface Payload {
10-
stepId: string
10+
stepId: string | null
1111
}
1212

1313
interface Callbacks {

web-app/src/services/logger/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { LOG, VERSION, NODE_ENV } from '../../environment'
22

3-
export type Log = string | object
3+
export type Log = string | object | null
44

55
const logger = (...messages: Log[]): void => {
66
if (!LOG) {

web-app/src/services/state/actions/context.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ const contextActions: ActionFunctionMap<T.MachineContext, T.MachineEvent> = {
230230
error: (): any => null,
231231
}),
232232
// @ts-ignore
233-
checkEmptySteps: send((context: T.MachineContext) => {
233+
checkLevelCompleted: send((context: T.MachineContext) => {
234234
// no step id indicates no steps to complete
235235
return {
236236
type: context.position.stepId === null ? 'START_COMPLETED_LEVEL' : 'START_LEVEL',

web-app/src/services/state/actions/editor.ts

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import * as CR from 'typings'
22
import * as TT from 'typings/tutorial'
33
import * as selectors from '../../selectors'
4+
import logger from 'services/logger'
45

56
export default (editorSend: any) => ({
67
startup(): void {
@@ -28,23 +29,28 @@ export default (editorSend: any) => ({
2829
},
2930
loadLevel(context: CR.MachineContext): void {
3031
const level: TT.Level = selectors.currentLevel(context)
32+
logger('loadStep', level)
3133
if (level.setup) {
3234
// load step actions
3335
editorSend({
3436
type: 'SETUP_ACTIONS',
35-
payload: level.setup,
37+
payload: {
38+
actions: level.setup,
39+
stepId: level.steps.length ? level.steps[0].id : null,
40+
},
3641
})
3742
}
3843
},
3944
loadStep(context: CR.MachineContext): void {
4045
const step: TT.Step | null = selectors.currentStep(context)
46+
logger('loadStep', step)
4147
if (step && step.setup) {
4248
// load step actions
4349
editorSend({
4450
type: 'SETUP_ACTIONS',
4551
payload: {
52+
actions: step.setup,
4653
stepId: step.id,
47-
...step.setup,
4854
},
4955
})
5056
}

web-app/src/services/state/machine.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ export const createMachine = (options: any) => {
150150
initial: 'Load',
151151
states: {
152152
Load: {
153-
onEntry: ['loadLevel', 'loadStep', 'checkEmptySteps'],
153+
onEntry: ['loadLevel', 'checkLevelCompleted'],
154154
on: {
155155
START_LEVEL: 'Normal',
156156
START_COMPLETED_LEVEL: 'LevelComplete',

0 commit comments

Comments
 (0)