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 738fb7a9790df0beccdd228d4ca3d21d74772a1f
4 changes: 2 additions & 2 deletions src/channel/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ class Channel implements Channel {
alreadyConfigured: true,
})
// update the current stepId on startup
vscode.commands.executeCommand(COMMANDS.SET_CURRENT_STEP, action.payload)
vscode.commands.executeCommand(COMMANDS.SET_CURRENT_STEP, action.payload.stepId)
return
} catch (e) {
const error = {
Expand Down Expand Up @@ -292,7 +292,7 @@ class Channel implements Channel {
case 'SOLUTION_ACTIONS':
await solutionActions({ actions: action.payload, send: this.send })
// run test following solution to update position
vscode.commands.executeCommand(COMMANDS.RUN_TEST, action.payload)
vscode.commands.executeCommand(COMMANDS.RUN_TEST, action.payload.stepId)
return

default:
Expand Down
8 changes: 4 additions & 4 deletions src/editor/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ interface CreateCommandProps {
export const createCommands = ({ extensionPath, workspaceState }: CreateCommandProps) => {
// React panel webview
let webview: any
let currentStepId = ''
let currentStepId: string | null = ''
let testRunner: any

return {
Expand Down Expand Up @@ -73,13 +73,13 @@ export const createCommands = ({ extensionPath, workspaceState }: CreateCommandP
},
})
},
[COMMANDS.SET_CURRENT_STEP]: ({ stepId }: Payload) => {
[COMMANDS.SET_CURRENT_STEP]: (stepId: string | null) => {
// set from last setup stepAction
currentStepId = stepId
},
[COMMANDS.RUN_TEST]: (current: Payload | undefined, onSuccess: () => void) => {
[COMMANDS.RUN_TEST]: (stepId: string | null | undefined, onSuccess: () => void) => {
// use stepId from client, or last set stepId
const payload: Payload = { stepId: current && current.stepId.length ? current.stepId : currentStepId }
const payload: Payload = { stepId: stepId ?? null }
testRunner(payload, onSuccess)
},
}
Expand Down
2 changes: 1 addition & 1 deletion src/services/testRunner/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { clearOutput, displayOutput } from './output'
import { formatFailOutput } from './formatOutput'

export interface Payload {
stepId: string
stepId: string | null
}

interface Callbacks {
Expand Down
2 changes: 1 addition & 1 deletion web-app/src/services/logger/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { LOG, VERSION, NODE_ENV } from '../../environment'

export type Log = string | object
export type Log = string | object | null

const logger = (...messages: Log[]): void => {
if (!LOG) {
Expand Down
2 changes: 1 addition & 1 deletion web-app/src/services/state/actions/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ const contextActions: ActionFunctionMap<T.MachineContext, T.MachineEvent> = {
error: (): any => null,
}),
// @ts-ignore
checkEmptySteps: send((context: T.MachineContext) => {
checkLevelCompleted: send((context: T.MachineContext) => {
// no step id indicates no steps to complete
return {
type: context.position.stepId === null ? 'START_COMPLETED_LEVEL' : 'START_LEVEL',
Expand Down
10 changes: 8 additions & 2 deletions web-app/src/services/state/actions/editor.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as CR from 'typings'
import * as TT from 'typings/tutorial'
import * as selectors from '../../selectors'
import logger from 'services/logger'

export default (editorSend: any) => ({
startup(): void {
Expand Down Expand Up @@ -28,23 +29,28 @@ export default (editorSend: any) => ({
},
loadLevel(context: CR.MachineContext): void {
const level: TT.Level = selectors.currentLevel(context)
logger('loadStep', level)
if (level.setup) {
// load step actions
editorSend({
type: 'SETUP_ACTIONS',
payload: level.setup,
payload: {
actions: level.setup,
stepId: level.steps.length ? level.steps[0].id : null,
},
})
}
},
loadStep(context: CR.MachineContext): void {
const step: TT.Step | null = selectors.currentStep(context)
logger('loadStep', step)
if (step && step.setup) {
// load step actions
editorSend({
type: 'SETUP_ACTIONS',
payload: {
actions: step.setup,
stepId: step.id,
...step.setup,
},
})
}
Expand Down
2 changes: 1 addition & 1 deletion web-app/src/services/state/machine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ export const createMachine = (options: any) => {
initial: 'Load',
states: {
Load: {
onEntry: ['loadLevel', 'loadStep', 'checkEmptySteps'],
onEntry: ['loadLevel', 'checkLevelCompleted'],
on: {
START_LEVEL: 'Normal',
START_COMPLETED_LEVEL: 'LevelComplete',
Expand Down