Skip to content

Commit a7f1527

Browse files
committed
continue progress
Signed-off-by: shmck <shawn.j.mckay@gmail.com>
1 parent a23f997 commit a7f1527

File tree

3 files changed

+21
-15
lines changed

3 files changed

+21
-15
lines changed

src/actions/setupActions.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,6 @@ import openFiles from './utils/openFiles'
66
import runCommands from './utils/runCommands'
77
import onError from '../services/sentry/onError'
88

9-
async function wait(ms: number) {
10-
return new Promise((resolve) => {
11-
setTimeout(resolve, ms)
12-
})
13-
}
14-
159
interface SetupActions {
1610
actions: TT.StepActions
1711
send: (action: T.Action) => void // send messages to client
@@ -35,8 +29,6 @@ export const setupActions = async ({ actions, send, path }: SetupActions): Promi
3529
// 3. start file watchers
3630
loadWatchers(watchers || [])
3731

38-
await wait(1000)
39-
4032
// 4. run command
4133
await runCommands({ commands: commands || [], send, path }).catch(onError)
4234
}

src/channel/index.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -284,12 +284,12 @@ class Channel implements Channel {
284284
return
285285
// load step actions (git commits, commands, open files)
286286
case 'SETUP_ACTIONS':
287-
await vscode.commands.executeCommand(COMMANDS.SET_CURRENT_STEP, action.payload)
288-
setupActions({ actions: action.payload, send: this.send })
287+
await vscode.commands.executeCommand(COMMANDS.SET_CURRENT_STEP, action.payload.stepId)
288+
setupActions({ actions: action.payload.actions, send: this.send })
289289
return
290290
// load solution step actions (git commits, commands, open files)
291291
case 'SOLUTION_ACTIONS':
292-
await solutionActions({ actions: action.payload, send: this.send })
292+
await solutionActions({ actions: action.payload.actions, send: this.send })
293293
// run test following solution to update position
294294
vscode.commands.executeCommand(COMMANDS.RUN_TEST, action.payload.stepId)
295295
return
@@ -326,13 +326,16 @@ class Channel implements Channel {
326326

327327
switch (actionType) {
328328
case 'TEST_PASS':
329+
logger(`TEST PASS ${action.payload.stepId}`)
329330
const tutorial = this.context.tutorial.get()
330331
if (!tutorial) {
331332
throw new Error('ERROR: Tutorial not found in test run')
332333
}
333334
// update local storage stepProgress
334-
const progress = this.context.progress.setStepComplete(tutorial, action.payload.stepId)
335-
this.context.position.setPositionFromProgress(tutorial, progress)
335+
if (action.payload.stepId) {
336+
const progress = this.context.progress.setStepComplete(tutorial, action.payload.stepId)
337+
this.context.position.setPositionFromProgress(tutorial, progress)
338+
}
336339
saveCommit()
337340
}
338341

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

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,25 @@ export default (editorSend: any) => ({
2929
},
3030
loadLevel(context: CR.MachineContext): void {
3131
const level: TT.Level = selectors.currentLevel(context)
32-
logger('loadStep', level)
32+
logger('loadLevel', level)
3333
if (level.setup) {
3434
// load step actions
3535
editorSend({
3636
type: 'SETUP_ACTIONS',
3737
payload: {
3838
actions: level.setup,
39-
stepId: level.steps.length ? level.steps[0].id : null,
39+
},
40+
})
41+
}
42+
// ensure level step is loaded before first step
43+
const firstStep = selectors.currentStep(context)
44+
logger('loadFirstStep', firstStep)
45+
if (firstStep) {
46+
editorSend({
47+
type: 'SETUP_ACTIONS',
48+
payload: {
49+
actions: firstStep.setup,
50+
stepId: firstStep.id,
4051
},
4152
})
4253
}

0 commit comments

Comments
 (0)