File tree Expand file tree Collapse file tree 1 file changed +15
-7
lines changed Expand file tree Collapse file tree 1 file changed +15
-7
lines changed Original file line number Diff line number Diff line change @@ -78,23 +78,31 @@ export default {
7878 console . log ( 'ACTION: tutorialLoad.progress' )
7979 return currentProgress
8080 } ,
81- position ( ) {
81+ position ( context : any ) : CR . Position {
8282 console . log ( 'ACTION: tutorialLoad.position' )
8383 if ( ! currentTutorial ) {
8484 throw new Error ( 'No Tutorial loaded' )
8585 }
8686 const { data } = currentTutorial
87-
88- const levelId = data . summary . levelList [ 0 ]
89- const stageId = data . levels [ levelId ] . stageList [ 0 ]
90- const stepId = data . stages [ stageId ] . stepList [ 0 ]
87+ const levelId = data . summary . levelList . find ( ( id : string ) => ! currentProgress . levels [ id ] )
88+ if ( ! levelId ) {
89+ throw new Error ( 'No level found on position load' )
90+ }
91+ const stageId = data . levels [ levelId ] . stageList . find ( ( id : string ) => ! currentProgress . stages [ id ] )
92+ if ( ! stageId ) {
93+ throw new Error ( 'No stage found on position load' )
94+ }
95+ const stepId = data . stages [ stageId ] . stepList . find ( ( id : string ) => ! currentProgress . steps [ id ] )
96+ if ( ! stepId ) {
97+ throw new Error ( 'No step found on position load' )
98+ }
9199
92100 const position = {
93101 levelId,
94102 stageId,
95- stepId,
103+ stepId
96104 }
97-
105+ console . log ( 'position' , position )
98106 return position
99107 }
100108 } ) ,
You can’t perform that action at this time.
0 commit comments