@@ -67,21 +67,46 @@ export const createMachine = (options: any) => {
6767 target : 'ContinueTutorial' ,
6868 actions : [ 'continueTutorial' ] ,
6969 } ,
70- NEW_TUTORIAL : {
71- target : 'SelectTutorial' ,
72- } ,
70+ NEW_TUTORIAL : 'SelectTutorial' ,
7371 } ,
7472 } ,
7573 SelectTutorial : {
7674 onEntry : [ 'clearStorage' ] ,
7775 id : 'start-new-tutorial' ,
7876 on : {
7977 TUTORIAL_START : {
80- target : '#tutorial ' ,
78+ target : 'LoadTutorial ' ,
8179 actions : [ 'newTutorial' ] ,
8280 } ,
8381 } ,
8482 } ,
83+ // TODO move Initialize into New Tutorial setup
84+ LoadTutorial : {
85+ invoke : {
86+ src : services . loadTutorial ,
87+ onDone : {
88+ target : 'Summary' ,
89+ actions : assign ( {
90+ tutorial : ( context , event ) => event . data ,
91+ } ) ,
92+ } ,
93+ onError : {
94+ target : 'Error' ,
95+ actions : assign ( {
96+ error : ( context , event ) => event . data ,
97+ } ) ,
98+ } ,
99+ } ,
100+ } ,
101+ Summary : {
102+ on : {
103+ BACK : 'SelectTutorial' ,
104+ LOAD_TUTORIAL : {
105+ target : '#tutorial' ,
106+ actions : [ 'initPosition' , 'initTutorial' ] ,
107+ } ,
108+ } ,
109+ } ,
85110 ContinueTutorial : {
86111 on : {
87112 TUTORIAL_START : {
@@ -95,7 +120,7 @@ export const createMachine = (options: any) => {
95120 } ,
96121 Tutorial : {
97122 id : 'tutorial' ,
98- initial : 'Initialize ' ,
123+ initial : 'LoadNext ' ,
99124 on : {
100125 // track commands
101126 COMMAND_START : {
@@ -112,33 +137,6 @@ export const createMachine = (options: any) => {
112137 } ,
113138 } ,
114139 states : {
115- // TODO move Initialize into New Tutorial setup
116- Initialize : {
117- invoke : {
118- src : services . initialize ,
119- onDone : {
120- target : 'Summary' ,
121- actions : assign ( {
122- tutorial : ( context , event ) => event . data ,
123- } ) ,
124- } ,
125- onError : {
126- target : 'Error' ,
127- actions : assign ( {
128- error : ( context , event ) => event . data ,
129- } ) ,
130- } ,
131- } ,
132- } ,
133- Error : { } ,
134- Summary : {
135- on : {
136- LOAD_TUTORIAL : {
137- target : 'Level' ,
138- actions : [ 'initPosition' , 'initTutorial' ] ,
139- } ,
140- } ,
141- } ,
142140 LoadNext : {
143141 id : 'tutorial-load-next' ,
144142 onEntry : [ 'loadNext' ] ,
0 commit comments