Skip to content

Fix/continue #255

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 9 commits into from
Prev Previous commit
Next Next commit
continue progress
Signed-off-by: shmck <shawn.j.mckay@gmail.com>
  • Loading branch information
ShMcK committed Apr 18, 2020
commit a7f15271be73c5421ffe5f4b2bad9d33976d44e3
8 changes: 0 additions & 8 deletions src/actions/setupActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,6 @@ import openFiles from './utils/openFiles'
import runCommands from './utils/runCommands'
import onError from '../services/sentry/onError'

async function wait(ms: number) {
return new Promise((resolve) => {
setTimeout(resolve, ms)
})
}

interface SetupActions {
actions: TT.StepActions
send: (action: T.Action) => void // send messages to client
Expand All @@ -35,8 +29,6 @@ export const setupActions = async ({ actions, send, path }: SetupActions): Promi
// 3. start file watchers
loadWatchers(watchers || [])

await wait(1000)

// 4. run command
await runCommands({ commands: commands || [], send, path }).catch(onError)
}
Expand Down
13 changes: 8 additions & 5 deletions src/channel/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -284,12 +284,12 @@ class Channel implements Channel {
return
// load step actions (git commits, commands, open files)
case 'SETUP_ACTIONS':
await vscode.commands.executeCommand(COMMANDS.SET_CURRENT_STEP, action.payload)
setupActions({ actions: action.payload, send: this.send })
await vscode.commands.executeCommand(COMMANDS.SET_CURRENT_STEP, action.payload.stepId)
setupActions({ actions: action.payload.actions, send: this.send })
return
// load solution step actions (git commits, commands, open files)
case 'SOLUTION_ACTIONS':
await solutionActions({ actions: action.payload, send: this.send })
await solutionActions({ actions: action.payload.actions, send: this.send })
// run test following solution to update position
vscode.commands.executeCommand(COMMANDS.RUN_TEST, action.payload.stepId)
return
Expand Down Expand Up @@ -326,13 +326,16 @@ class Channel implements Channel {

switch (actionType) {
case 'TEST_PASS':
logger(`TEST PASS ${action.payload.stepId}`)
const tutorial = this.context.tutorial.get()
if (!tutorial) {
throw new Error('ERROR: Tutorial not found in test run')
}
// update local storage stepProgress
const progress = this.context.progress.setStepComplete(tutorial, action.payload.stepId)
this.context.position.setPositionFromProgress(tutorial, progress)
if (action.payload.stepId) {
const progress = this.context.progress.setStepComplete(tutorial, action.payload.stepId)
this.context.position.setPositionFromProgress(tutorial, progress)
}
saveCommit()
}

Expand Down
15 changes: 13 additions & 2 deletions web-app/src/services/state/actions/editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,25 @@ export default (editorSend: any) => ({
},
loadLevel(context: CR.MachineContext): void {
const level: TT.Level = selectors.currentLevel(context)
logger('loadStep', level)
logger('loadLevel', level)
if (level.setup) {
// load step actions
editorSend({
type: 'SETUP_ACTIONS',
payload: {
actions: level.setup,
stepId: level.steps.length ? level.steps[0].id : null,
},
})
}
// ensure level step is loaded before first step
const firstStep = selectors.currentStep(context)
logger('loadFirstStep', firstStep)
if (firstStep) {
editorSend({
type: 'SETUP_ACTIONS',
payload: {
actions: firstStep.setup,
stepId: firstStep.id,
},
})
}
Expand Down