Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 738fb7a

Browse files
committed
continue progress
Signed-off-by: shmck <[email protected]>
1 parent b8ff86b commit 738fb7a

File tree

7 files changed

+18
-12
lines changed

7 files changed

+18
-12
lines changed

src/channel/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ class Channel implements Channel {
223223
alreadyConfigured: true,
224224
})
225225
// update the current stepId on startup
226-
vscode.commands.executeCommand(COMMANDS.SET_CURRENT_STEP, action.payload)
226+
vscode.commands.executeCommand(COMMANDS.SET_CURRENT_STEP, action.payload.stepId)
227227
return
228228
} catch (e) {
229229
const error = {
@@ -292,7 +292,7 @@ class Channel implements Channel {
292292
case 'SOLUTION_ACTIONS':
293293
await solutionActions({ actions: action.payload, send: this.send })
294294
// run test following solution to update position
295-
vscode.commands.executeCommand(COMMANDS.RUN_TEST, action.payload)
295+
vscode.commands.executeCommand(COMMANDS.RUN_TEST, action.payload.stepId)
296296
return
297297

298298
default:

src/editor/commands.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ interface CreateCommandProps {
2020
export const createCommands = ({ extensionPath, workspaceState }: CreateCommandProps) => {
2121
// React panel webview
2222
let webview: any
23-
let currentStepId = ''
23+
let currentStepId: string | null = ''
2424
let testRunner: any
2525

2626
return {
@@ -73,13 +73,13 @@ export const createCommands = ({ extensionPath, workspaceState }: CreateCommandP
7373
},
7474
})
7575
},
76-
[COMMANDS.SET_CURRENT_STEP]: ({ stepId }: Payload) => {
76+
[COMMANDS.SET_CURRENT_STEP]: (stepId: string | null) => {
7777
// set from last setup stepAction
7878
currentStepId = stepId
7979
},
80-
[COMMANDS.RUN_TEST]: (current: Payload | undefined, onSuccess: () => void) => {
80+
[COMMANDS.RUN_TEST]: (stepId: string | null | undefined, onSuccess: () => void) => {
8181
// use stepId from client, or last set stepId
82-
const payload: Payload = { stepId: current && current.stepId.length ? current.stepId : currentStepId }
82+
const payload: Payload = { stepId: stepId ?? null }
8383
testRunner(payload, onSuccess)
8484
},
8585
}

src/services/testRunner/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { clearOutput, displayOutput } from './output'
88
import { formatFailOutput } from './formatOutput'
99

1010
export interface Payload {
11-
stepId: string
11+
stepId: string | null
1212
}
1313

1414
interface Callbacks {

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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 8 additions & 2 deletions
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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ export const createMachine = (options: any) => {
157157
initial: 'Load',
158158
states: {
159159
Load: {
160-
onEntry: ['loadLevel', 'loadStep', 'checkEmptySteps'],
160+
onEntry: ['loadLevel', 'checkLevelCompleted'],
161161
on: {
162162
START_LEVEL: 'Normal',
163163
START_COMPLETED_LEVEL: 'LevelComplete',

0 commit comments

Comments
 (0)