Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
ShMcK merged 3 commits intomasterfromfeature/completion-hooks
Aug 2, 2020
Merged
Show file tree
Hide file tree
Changes fromall commits
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
14 changes: 12 additions & 2 deletionssrc/channel.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -55,12 +55,13 @@ class Channel implements Channel {
openWorkspace()
return
// load step actions (git commits, commands, open files)
case'SETUP_ACTIONS':
case'EDITOR_LEVEL_ENTER':
case'EDITOR_STEP_ENTER':
awaitvscode.commands.executeCommand(COMMANDS.SET_CURRENT_POSITION,action.payload.position)
hooks.onSetupEnter(action.payload.actions)
return
// load solution step actions (git commits, commands, open files)
case'SOLUTION_ACTIONS':
case'EDITOR_SOLUTION_ENTER':
awaitvscode.commands.executeCommand(COMMANDS.SET_CURRENT_POSITION,action.payload.position)
hooks.onSolutionEnter(action.payload.actions)
return
Expand All@@ -80,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
14 changes: 14 additions & 0 deletionssrc/services/hooks/index.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
import*asTfrom'typings'
import*asTTfrom'typings/tutorial'
import*asgitfrom'../git'
importloadCommitsfrom'./utils/loadCommits'
Expand All@@ -7,6 +8,7 @@ import runCommands from './utils/runCommands'
importrunVSCodeCommandsfrom'./utils/runVSCodeCommands'
import{onErrorastelemetryOnError}from'../telemetry'
import{onRunTest}from'../../actions/onTest'
importloggerfrom'../logger'

exportconstonInit=async(actions:TT.StepActions):Promise<void>=>{
awaitloadCommits(actions?.commits)
Expand DownExpand Up@@ -39,3 +41,15 @@ export const onSolutionEnter = async (actions: TT.StepActions): Promise<void> =>
exportconstonError=async(error:Error):Promise<void>=>{
telemetryOnError(error)
}

exportconstonStepComplete=async({ levelId, stepId}:{levelId:string;stepId:string}):Promise<void>=>{
logger(`ON STEP COMPLETE:${JSON.stringify({ levelId, stepId})}`)
}

exportconstonLevelComplete=async({ levelId}:{levelId:string}):Promise<void>=>{
logger(`ON LEVEL COMPLETE:${JSON.stringify(levelId)}`)
}

exportconstonTutorialComplete=async({ tutorialId}:{tutorialId:string}):Promise<void>=>{
logger(`ON TUTORIAL COMPLETE:${JSON.stringify(tutorialId)}`)
}
31 changes: 28 additions & 3 deletionsweb-app/src/services/state/actions/editor.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -32,7 +32,7 @@ export default (editorSend: any) => ({
conststep:TT.Step|null=selectors.currentStep(context)
// load step actions
editorSend({
type:'SETUP_ACTIONS',
type:'EDITOR_LEVEL_ENTER',
payload:{
position:{
stepId:step?.id||null,
Expand All@@ -48,7 +48,7 @@ export default (editorSend: any) => ({
if(step&&step.setup){
// load step actions
editorSend({
type:'SETUP_ACTIONS',
type:'EDITOR_STEP_ENTER',
payload:{
// set position here
position:{
Expand DownExpand Up@@ -76,7 +76,7 @@ export default (editorSend: any) => ({
// tell editor to load solution commit
if(step&&step.solution){
editorSend({
type:'SOLUTION_ACTIONS',
type:'EDITOR_SOLUTION_ENTER',
payload:{
position:{
stepId:step.id,
Expand DownExpand Up@@ -133,4 +133,29 @@ export default (editorSend: any) => ({
},
})
},
onStepComplete(context:T.MachineContext):void{
editorSend({
type:'EDITOR_STEP_COMPLETE',
payload:{
levelId:context.position.levelId,
stepId:context.position.levelId,
},
})
},
onLevelComplete(context:T.MachineContext):void{
editorSend({
type:'EDITOR_LEVEL_COMPLETE',
payload:{
levelId:context.position.levelId,
},
})
},
onTutorialComplete(context:T.MachineContext):void{
editorSend({
type:'EDITOR_TUTORIAL_COMPLETE',
payload:{
tutorialId:context.tutorial?.id,
},
})
},
})
13 changes: 9 additions & 4 deletionsweb-app/src/services/state/machine.ts
View file
Open in desktop
Original file line numberDiff line numberDiff 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@@ -200,7 +200,10 @@ export const createMachine = (options: any) => {
target: 'Normal',
actions: ['loadStep', 'updateStepPosition'],
},
LEVEL_COMPLETE: 'LevelComplete',
LEVEL_COMPLETE: {
target: 'LevelComplete',
actions: ['onLevelComplete'],
},
},
},
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

[8]ページ先頭

©2009-2025 Movatter.jp