1
1
import * as CR from 'typings'
2
- import { assign , Machine , MachineOptions , actions } from 'xstate'
2
+ import { assign , Machine , MachineOptions } from 'xstate'
3
3
import editorActions from './actions/editor'
4
4
import commandActions from './actions/command'
5
5
import contextActions from './actions/context'
@@ -72,18 +72,18 @@ export const createMachine = (options: any) => {
72
72
} ,
73
73
SelectTutorial :{
74
74
onEntry :[ 'clearStorage' ] ,
75
- id :'start -new-tutorial' ,
75
+ id :'select -new-tutorial' ,
76
76
on :{
77
77
SELECT_TUTORIAL :{
78
- target :'LoadTutorial ' ,
78
+ target :'LoadTutorialSummary ' ,
79
79
actions :[ 'newTutorial' ] ,
80
80
} ,
81
81
} ,
82
82
} ,
83
83
// TODO move Initialize into New Tutorial setup
84
- LoadTutorial :{
84
+ LoadTutorialSummary :{
85
85
invoke :{
86
- src :services . loadTutorial ,
86
+ src :services . loadTutorialSummary ,
87
87
onDone :{
88
88
target :'Summary' ,
89
89
actions :assign ( {
@@ -102,9 +102,31 @@ export const createMachine = (options: any) => {
102
102
on :{
103
103
BACK :'SelectTutorial' ,
104
104
TUTORIAL_START :{
105
- target :'#tutorial' ,
106
- actions :[ 'initPosition' , 'initTutorial' ] ,
105
+ target :'LoadTutorialData' ,
106
+ } ,
107
+ } ,
108
+ } ,
109
+ LoadTutorialData :{
110
+ invoke :{
111
+ src :services . loadTutorialData ,
112
+ onDone :{
113
+ target :'SetupNewTutorial' ,
114
+ actions :assign ( {
115
+ tutorial :( context , event ) => event . data ,
116
+ } ) ,
107
117
} ,
118
+ onError :{
119
+ target :'Error' ,
120
+ actions :assign ( {
121
+ error :( context , event ) => event . data ,
122
+ } ) ,
123
+ } ,
124
+ } ,
125
+ } ,
126
+ SetupNewTutorial :{
127
+ onEntry :[ 'configureNewTutorial' , 'initPosition' ] ,
128
+ after :{
129
+ 0 :'#tutorial' ,
108
130
} ,
109
131
} ,
110
132
ContinueTutorial :{
@@ -224,7 +246,7 @@ export const createMachine = (options: any) => {
224
246
onEntry :[ 'userTutorialComplete' ] ,
225
247
on :{
226
248
SELECT_TUTORIAL :{
227
- target :'#start -new-tutorial' ,
249
+ target :'#select -new-tutorial' ,
228
250
actions :[ 'reset' ] ,
229
251
} ,
230
252
} ,