File tree Expand file tree Collapse file tree 2 files changed +12
-4
lines changed
web-app/src/services/state/actions Expand file tree Collapse file tree 2 files changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -113,10 +113,18 @@ export const clearError = assign({
113113} )
114114
115115export const checkLevelCompleted = send ( ( context : T . MachineContext ) => {
116- // no step id indicates no steps to complete
117- logger ( context . position )
116+ const currentLevel = selectors . currentLevel ( context )
117+ let hasNoSteps = false
118+ let finalStepComplete = false
119+ if ( ! currentLevel . steps . length ) {
120+ hasNoSteps = true
121+ } else {
122+ const finalStep = currentLevel . steps [ currentLevel . steps . length - 1 ]
123+ finalStepComplete = finalStep . id === context . position . stepId && context . position . complete
124+ }
125+
118126 return {
119- type : context . position . stepId === null ? 'START_COMPLETED_LEVEL' : 'START_LEVEL' ,
127+ type : hasNoSteps || finalStepComplete ? 'START_COMPLETED_LEVEL' : 'START_LEVEL' ,
120128 }
121129} )
122130
Original file line number Diff line number Diff line change @@ -129,7 +129,7 @@ export default (editorSend: any) => ({
129129 editorSend ( {
130130 type : 'EDITOR_SYNC_POSITION' ,
131131 payload : {
132- position : { ... context . position , complete : true } ,
132+ position : context . position ,
133133 } ,
134134 } )
135135 } ,
You can’t perform that action at this time.
0 commit comments