File tree Expand file tree Collapse file tree 7 files changed +40
-38
lines changed Expand file tree Collapse file tree 7 files changed +40
-38
lines changed Original file line number Diff line number Diff line change @@ -76,7 +76,6 @@ export interface MachineStateSchema {
7676 }
7777 Tutorial : {
7878 states : {
79- LoadNext : { }
8079 Level : {
8180 states : {
8281 Load : { }
@@ -86,6 +85,7 @@ export interface MachineStateSchema {
8685 TestFail : { }
8786 StepNext : { }
8887 LevelComplete : { }
88+ LoadNext : { }
8989 }
9090 }
9191 Completed : { }
Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ const Routes = () => {
2020 )
2121 }
2222
23+ console . log ( 'RENDER' )
2324 return (
2425 < Workspace >
2526 < Router >
@@ -37,10 +38,10 @@ const Routes = () => {
3738 < LoadingPage text = "Configuring tutorial..." />
3839 </ Route >
3940 { /* Tutorial */ }
40- < Route path = { [ 'Tutorial.LoadNext' , 'Tutorial. Level.Load'] } >
41+ < Route path = { [ 'Tutorial.Level.Load' ] } >
4142 < LoadingPage text = "Loading Level..." processes = { context . processes } />
4243 </ Route >
43- < Route path = " Tutorial.Level" >
44+ < Route path = { [ ' Tutorial.LoadNext' , 'Tutorial. Level' ] } >
4445 < TutorialPage send = { send } context = { context } />
4546 </ Route >
4647 { /* Completed */ }
Original file line number Diff line number Diff line change @@ -30,7 +30,7 @@ const useRouter = (): Output => {
3030 send ( action )
3131 }
3232
33- logger ( `STATE: ${ JSON . stringify ( state . value ) } ` )
33+ console . log ( `STATE: ${ JSON . stringify ( state . value ) } ` )
3434
3535 // event bus listener
3636 React . useEffect ( ( ) => {
Original file line number Diff line number Diff line change @@ -26,8 +26,6 @@ interface Props {
2626const Hints = ( props : Props ) => {
2727 const isFinalHint = props . hints . length - 1 === props . hintIndex
2828 const nextHint = ( ) => {
29- console . log ( 'hintIndex' )
30- console . log ( props . hintIndex )
3129 if ( isFinalHint ) {
3230 return
3331 }
Original file line number Diff line number Diff line change @@ -99,8 +99,6 @@ interface Props {
9999 onRunTest ( ) : void
100100 onLoadSolution ( ) : void
101101 onOpenLogs ( channel : string ) : void
102- displayHintsIndex : number [ ]
103- setHintsIndex ( index : number , value : number ) : void
104102}
105103
106104const Level = ( {
@@ -115,14 +113,31 @@ const Level = ({
115113 onOpenLogs,
116114 processes,
117115 testStatus,
118- displayHintsIndex,
119- setHintsIndex,
120116} : Props ) => {
121117 const level = tutorial . levels [ index ]
122118
123119 const [ title , setTitle ] = React . useState < string > ( level . title )
124120 const [ content , setContent ] = React . useState < string > ( level . content )
125121
122+ // hold state for hints for the level
123+ const [ displayHintsIndex , setDisplayHintsIndex ] = React . useState < number [ ] > ( [ ] )
124+ const setHintsIndex = ( index : number , value : number ) => {
125+ return setDisplayHintsIndex ( ( displayHintsIndex ) => {
126+ const next = [ ...displayHintsIndex ]
127+ next [ index ] = value
128+ return next
129+ } )
130+ }
131+ React . useEffect ( ( ) => {
132+ console . log ( position . levelId )
133+ console . log ( JSON . stringify ( position ) )
134+ // set the hints to empty on level starts
135+ setDisplayHintsIndex ( steps . map ( ( s ) => - 1 ) )
136+ return ( ) => {
137+ console . log ( 'LEVEL UNMOUNTED' )
138+ }
139+ } , [ position . levelId ] )
140+
126141 const menu = (
127142 < ContentMenu
128143 tutorial = { tutorial }
Original file line number Diff line number Diff line change @@ -37,16 +37,6 @@ const TutorialPage = (props: PageProps) => {
3737
3838 const levelIndex = tutorial . levels . findIndex ( ( l : TT . Level ) => l . id === position . levelId )
3939 const levelStatus = progress . levels [ position . levelId ] ? 'COMPLETE' : 'ACTIVE'
40- const { steps } = tutorial . levels [ levelIndex ]
41- const [ displayHintsIndex , setDisplayHintsIndex ] = React . useState < number [ ] > ( steps . map ( ( s ) => - 1 ) )
42-
43- const setHintsIndex = ( index : number , value : number ) => {
44- return setDisplayHintsIndex ( ( displayHintsIndex ) => {
45- const next = [ ...displayHintsIndex ]
46- next [ index ] = value
47- return next
48- } )
49- }
5040
5141 return (
5242 < Level
@@ -61,8 +51,6 @@ const TutorialPage = (props: PageProps) => {
6151 onOpenLogs = { onOpenLogs }
6252 processes = { processes }
6353 testStatus = { testStatus }
64- displayHintsIndex = { displayHintsIndex }
65- setHintsIndex = { setHintsIndex }
6654 />
6755 )
6856}
Original file line number Diff line number Diff line change @@ -142,21 +142,6 @@ export const createMachine = (options: any) => {
142142 id : 'tutorial' ,
143143 initial : 'Level' ,
144144 states : {
145- LoadNext : {
146- id : 'tutorial-load-next' ,
147- onEntry : [ 'loadNext' ] ,
148- on : {
149- NEXT_STEP : {
150- target : 'Level' ,
151- actions : [ 'updatePosition' ] ,
152- } ,
153- NEXT_LEVEL : {
154- target : 'Level' ,
155- actions : [ 'updatePosition' ] ,
156- } ,
157- COMPLETED : '#completed-tutorial' ,
158- } ,
159- } ,
160145 Level : {
161146 initial : 'Load' ,
162147 states : {
@@ -228,11 +213,26 @@ export const createMachine = (options: any) => {
228213 onExit : [ 'syncLevelProgress' ] ,
229214 on : {
230215 NEXT_LEVEL : {
231- target : '#tutorial-load-next ' ,
216+ target : 'LoadNext ' ,
232217 actions : [ 'testClear' , 'updatePosition' ] ,
233218 } ,
234219 } ,
235220 } ,
221+ LoadNext : {
222+ id : 'tutorial-load-next' ,
223+ onEntry : [ 'loadNext' ] ,
224+ on : {
225+ NEXT_STEP : {
226+ target : 'Load' ,
227+ actions : [ 'updatePosition' ] ,
228+ } ,
229+ NEXT_LEVEL : {
230+ target : 'Load' ,
231+ actions : [ 'updatePosition' ] ,
232+ } ,
233+ COMPLETED : '#completed-tutorial' ,
234+ } ,
235+ } ,
236236 } ,
237237 } ,
238238 Completed : {
You can’t perform that action at this time.
0 commit comments