1- import * as CR from 'typings'
1+ import * as T from 'typings'
22import * as G from 'typings/graphql'
33import { assign , send , ActionFunctionMap } from 'xstate'
44import * as selectors from '../../selectors'
55import onError from '../../../services/sentry/onError'
66
7- const contextActions : ActionFunctionMap < CR . MachineContext , CR . MachineEvent > = {
7+ const contextActions : ActionFunctionMap < T . MachineContext , T . MachineEvent > = {
88 // @ts -ignore
99 setEnv : assign ( {
10- env : ( context : CR . MachineContext , event : CR . MachineEvent ) => {
10+ env : ( context : T . MachineContext , event : T . MachineEvent ) => {
1111 return {
1212 ...context . env ,
1313 ...event . payload . env ,
@@ -16,35 +16,35 @@ const contextActions: ActionFunctionMap<CR.MachineContext, CR.MachineEvent> = {
1616 } ) ,
1717 // @ts -ignore
1818 continueTutorial : assign ( {
19- tutorial : ( context : CR . MachineContext , event : CR . MachineEvent ) => {
19+ tutorial : ( context : T . MachineContext , event : T . MachineEvent ) => {
2020 return event . payload . tutorial
2121 } ,
22- progress : ( context : CR . MachineContext , event : CR . MachineEvent ) => {
22+ progress : ( context : T . MachineContext , event : T . MachineEvent ) => {
2323 return event . payload . progress
2424 } ,
25- position : ( context : CR . MachineContext , event : CR . MachineEvent ) => {
25+ position : ( context : T . MachineContext , event : T . MachineEvent ) => {
2626 return event . payload . position
2727 } ,
2828 } ) ,
2929 // @ts -ignore
3030 selectTutorialById : assign ( {
31- tutorial : ( context : CR . MachineContext , event : CR . MachineEvent ) : any => {
31+ tutorial : ( context : T . MachineContext , event : T . MachineEvent ) : any => {
3232 return event . payload . tutorial
3333 } ,
3434 } ) ,
3535 // @ts -ignore
3636 startNewTutorial : assign ( {
37- position : ( context : CR . MachineContext , event : CR . MachineEvent ) : CR . Position => {
38- const position : CR . Position = selectors . initialPosition ( context )
37+ position : ( context : T . MachineContext , event : T . MachineEvent ) : any => {
38+ const position : T . Position = selectors . initialPosition ( context )
3939 return position
4040 } ,
41- progress : ( ) : CR . Progress => {
41+ progress : ( ) : T . Progress => {
4242 return { levels : { } , steps : { } , complete : false }
4343 } ,
4444 } ) ,
4545 // @ts -ignore
4646 updateStepPosition : assign ( {
47- position : ( context : CR . MachineContext , event : CR . MachineEvent ) : CR . Position => {
47+ position : ( context : T . MachineContext , event : T . MachineEvent ) : any => {
4848 // TODO calculate from progress
4949
5050 const { position } = context
@@ -62,7 +62,7 @@ const contextActions: ActionFunctionMap<CR.MachineContext, CR.MachineEvent> = {
6262
6363 const step : G . Step = steps [ stepIndex + 1 ]
6464
65- const nextPosition : CR . Position = {
65+ const nextPosition : T . Position = {
6666 ...position ,
6767 stepId : step . id ,
6868 }
@@ -72,7 +72,7 @@ const contextActions: ActionFunctionMap<CR.MachineContext, CR.MachineEvent> = {
7272 } ) ,
7373 // @ts -ignore
7474 updateLevelPosition : assign ( {
75- position : ( context : CR . MachineContext ) : CR . Position => {
75+ position : ( context : T . MachineContext ) : any => {
7676 const { position } = context
7777 const version = selectors . currentVersion ( context )
7878 // merge in the updated position
@@ -82,7 +82,7 @@ const contextActions: ActionFunctionMap<CR.MachineContext, CR.MachineEvent> = {
8282 const levelIndex = levels . findIndex ( ( l : G . Level ) => l . id === position . levelId )
8383 const level : G . Level = levels [ levelIndex + 1 ]
8484
85- const nextPosition : CR . Position = {
85+ const nextPosition : T . Position = {
8686 levelId : level . id ,
8787 stepId : level . steps [ 0 ] . id ,
8888 }
@@ -92,7 +92,7 @@ const contextActions: ActionFunctionMap<CR.MachineContext, CR.MachineEvent> = {
9292 } ) ,
9393 // @ts -ignore
9494 updateLevelProgress : assign ( {
95- progress : ( context : CR . MachineContext , event : CR . MachineEvent ) : CR . Progress => {
95+ progress : ( context : T . MachineContext , event : T . MachineEvent ) : any => {
9696 // update progress by tracking completed
9797 const { progress, position } = context
9898
@@ -105,9 +105,9 @@ const contextActions: ActionFunctionMap<CR.MachineContext, CR.MachineEvent> = {
105105 } ) ,
106106 // @ts -ignore
107107 updateStepProgress : assign ( {
108- progress : ( context : CR . MachineContext , event : CR . MachineEvent ) : CR . Progress => {
108+ progress : ( context : T . MachineContext , event : T . MachineEvent ) : any => {
109109 // update progress by tracking completed
110- const currentProgress : CR . Progress = context . progress
110+ const currentProgress : T . Progress = context . progress
111111
112112 const { stepId } = event . payload
113113
@@ -118,13 +118,13 @@ const contextActions: ActionFunctionMap<CR.MachineContext, CR.MachineEvent> = {
118118 } ) ,
119119 // @ts -ignore
120120 updatePosition : assign ( {
121- position : ( context : CR . MachineContext , event : CR . MachineEvent ) : CR . Progress => {
121+ position : ( context : T . MachineContext , event : T . MachineEvent ) : any => {
122122 const { position } = event . payload
123123 return position
124124 } ,
125125 } ) ,
126126 loadNext : send (
127- ( context : CR . MachineContext ) : CR . Action => {
127+ ( context : T . MachineContext ) : T . Action => {
128128 const { position, progress } = context
129129
130130 const level = selectors . currentLevel ( context )
@@ -170,7 +170,7 @@ const contextActions: ActionFunctionMap<CR.MachineContext, CR.MachineEvent> = {
170170 } ,
171171 ) ,
172172 stepNext : send (
173- ( context : CR . MachineContext ) : CR . Action => {
173+ ( context : T . MachineContext ) : T . Action => {
174174 const { position, progress } = context
175175
176176 const level : G . Level = selectors . currentLevel ( context )
@@ -203,19 +203,20 @@ const contextActions: ActionFunctionMap<CR.MachineContext, CR.MachineEvent> = {
203203 tutorial ( ) {
204204 return null
205205 } ,
206- progress ( ) : CR . Progress {
207- const progress : CR . Progress = selectors . defaultProgress ( )
206+ progress ( ) : T . Progress {
207+ const progress : T . Progress = selectors . defaultProgress ( )
208208 return progress
209209 } ,
210- position ( ) : CR . Position {
211- const position : CR . Position = selectors . defaultPosition ( )
210+ position ( ) : T . Position {
211+ const position : T . Position = selectors . defaultPosition ( )
212212 return position
213213 } ,
214214 } ) ,
215215 // @ts -ignore
216216 setError : assign ( {
217- error : ( context : CR . MachineContext , event : CR . MachineEvent ) : string | null => {
218- return event . payload . error
217+ error : ( context : T . MachineContext , event : T . MachineEvent ) : any => {
218+ const message : string | null = event . payload . error
219+ return message
219220 } ,
220221 } ) ,
221222}
0 commit comments