Skip to content

Feature/completion hooks #420

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

Merged
merged 3 commits into from
Aug 2, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
setup step/level/tutorial complete tracking
Signed-off-by: shmck <shawn.j.mckay@gmail.com>
  • Loading branch information
ShMcK committed Aug 2, 2020
commit cf4095f120ffcfc3216a321c6a2cc5f83d270bf9
9 changes: 9 additions & 0 deletions src/channel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,15 @@ class Channel implements Channel {
case 'EDITOR_RUN_RESET_POSITION':
actions.onRunReset({ type: 'POSITION', position: action.payload.position }, this.context)
return
case 'EDITOR_STEP_COMPLETE':
hooks.onStepComplete(action.payload)
return
case 'EDITOR_LEVEL_COMPLETE':
hooks.onLevelComplete(action.payload)
return
case 'EDITOR_TUTORIAL_COMPLETE':
hooks.onTutorialComplete(action.payload)
return
default:
logger(`No match for action type: ${actionType}`)
return
Expand Down
16 changes: 16 additions & 0 deletions src/services/hooks/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import * as T from 'typings'
import * as TT from 'typings/tutorial'
import * as git from '../git'
import loadCommits from './utils/loadCommits'
Expand Down Expand Up @@ -39,3 +40,18 @@ export const onSolutionEnter = async (actions: TT.StepActions): Promise<void> =>
export const onError = async (error: Error): Promise<void> => {
telemetryOnError(error)
}

export const onStepComplete = async ({ position }: { position: T.Position }): Promise<void> => {
/* TODO */
console.log(`ON STEP COMPLETE: ${JSON.stringify(position)}`)
}

export const onLevelComplete = async ({ position }: { position: T.Position }): Promise<void> => {
/* TODO */
console.log(`ON LEVEL COMPLETE: ${JSON.stringify(position)}`)
}

export const onTutorialComplete = async ({ position }: { position: T.Position }): Promise<void> => {
/* TODO */
console.log(`ON LEVEL COMPLETE: ${JSON.stringify(position)}`)
}
24 changes: 24 additions & 0 deletions web-app/src/services/state/actions/editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,4 +133,28 @@ export default (editorSend: any) => ({
},
})
},
onStepComplete(context: T.MachineContext): void {
editorSend({
type: 'EDITOR_STEP_COMPLETE',
payload: {
position: context.position,
},
})
},
onLevelComplete(context: T.MachineContext): void {
editorSend({
type: 'EDITOR_LEVEL_COMPLETE',
payload: {
position: context.position,
},
})
},
onTutorialComplete(context: T.MachineContext): void {
editorSend({
type: 'EDITOR_TUTORIAL_COMPLETE',
payload: {
position: context.position,
},
})
},
})
13 changes: 9 additions & 4 deletions web-app/src/services/state/machine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,12 @@ export const createMachine = (options: any) => {
on: {
LOAD_NEXT_STEP: {
target: 'Normal',
actions: ['loadStep', 'updateStepPosition'],
actions: ['onStepComplete', 'loadStep', 'updateStepPosition'],
},
LEVEL_COMPLETE: {
target: 'LevelComplete',
actions: ['onLevelComplete'],
},
LEVEL_COMPLETE: 'LevelComplete',
},
},
LevelComplete: {
Expand All @@ -223,14 +226,16 @@ export const createMachine = (options: any) => {
target: 'Load',
actions: ['updatePosition'],
},
COMPLETED: '#completed-tutorial',
COMPLETED: {
target: '#completed-tutorial',
actions: ['onTutorialComplete'],
},
},
},
},
},
Completed: {
id: 'completed-tutorial',
onEntry: ['userTutorialComplete'], // unusued
on: {
SELECT_TUTORIAL: {
target: '#select-new-tutorial',
Expand Down