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

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
limit hook payloads
Signed-off-by: shmck <[email protected]>
  • Loading branch information
ShMcK committed Aug 2, 2020
commit 78c2c1d45675d4d18e3e316207574c69b577a55d
16 changes: 7 additions & 9 deletions src/services/hooks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import runCommands from './utils/runCommands'
import runVSCodeCommands from './utils/runVSCodeCommands'
import { onError as telemetryOnError } from '../telemetry'
import { onRunTest } from '../../actions/onTest'
import logger from '../logger'

export const onInit = async (actions: TT.StepActions): Promise<void> => {
await loadCommits(actions?.commits)
Expand Down Expand Up @@ -41,17 +42,14 @@ 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 onStepComplete = async ({ levelId, stepId }: { levelId: string; stepId: string }): Promise<void> => {
logger(`ON STEP COMPLETE: ${JSON.stringify({ levelId, stepId })}`)
}

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

export const onTutorialComplete = async ({ position }: { position: T.Position }): Promise<void> => {
/* TODO */
console.log(`ON LEVEL COMPLETE: ${JSON.stringify(position)}`)
export const onTutorialComplete = async ({ tutorialId }: { tutorialId: string }): Promise<void> => {
logger(`ON TUTORIAL COMPLETE: ${JSON.stringify(tutorialId)}`)
}
7 changes: 4 additions & 3 deletions web-app/src/services/state/actions/editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,23 +137,24 @@ export default (editorSend: any) => ({
editorSend({
type: 'EDITOR_STEP_COMPLETE',
payload: {
position: context.position,
levelId: context.position.levelId,
stepId: context.position.levelId,
},
})
},
onLevelComplete(context: T.MachineContext): void {
editorSend({
type: 'EDITOR_LEVEL_COMPLETE',
payload: {
position: context.position,
levelId: context.position.levelId,
},
})
},
onTutorialComplete(context: T.MachineContext): void {
editorSend({
type: 'EDITOR_TUTORIAL_COMPLETE',
payload: {
position: context.position,
tutorialId: context.tutorial?.id,
},
})
},
Expand Down
4 changes: 2 additions & 2 deletions web-app/src/services/state/machine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ export const createMachine = (options: any) => {
on: {
TEST_PASS: {
target: 'StepNext',
actions: ['testPass', 'updateStepPosition'],
actions: ['onStepComplete', 'testPass', 'updateStepPosition'],
},
TEST_FAIL: {
target: 'Normal',
Expand All @@ -198,7 +198,7 @@ export const createMachine = (options: any) => {
on: {
LOAD_NEXT_STEP: {
target: 'Normal',
actions: ['onStepComplete', 'loadStep', 'updateStepPosition'],
actions: ['loadStep', 'updateStepPosition'],
},
LEVEL_COMPLETE: {
target: 'LevelComplete',
Expand Down