@@ -4,60 +4,17 @@ import * as CR from 'typings'
4
4
import * as selectors from '../../selectors'
5
5
6
6
export default {
7
- continueTutorial : ( context : CR . MachineContext , event : CR . MachineEvent ) => {
8
-
9
- const { tutorial, stepProgress} = event . payload
10
- // NOTE: tutorial does not contain levels/stages/steps etc.
11
-
12
- const progress : CR . Progress = {
13
- steps : stepProgress ,
14
- stages : { } ,
15
- levels : { } ,
16
- complete : false
17
- }
18
-
19
- const position : CR . Position = {
20
- stepId : '' ,
21
- stageId : '' ,
22
- levelId : '' ,
23
- }
24
-
25
- // calculate progress from tutorial & stepProgress
26
- for ( const level of tutorial . version . levels ) {
27
- for ( const stage of level . stages ) {
28
- // set stage progress
29
- const stageComplete : boolean = stage . steps . every ( ( step : G . Step ) => {
30
- return stepProgress [ step . id ]
31
- } )
32
- if ( stageComplete ) {
33
- progress . stages [ stage . id ] = true
34
- } else if ( ! position . stageId . length ) {
35
- // set stage amd step position
36
- position . stageId = stage . id
37
- position . stepId = stage . steps . find ( ( step : G . Step ) => ! stepProgress [ step . id ] ) . id
38
- }
39
- }
40
- // set level progress
41
- const levelComplete : boolean = level . stages . every ( ( stage : G . Stage ) => {
42
- return progress . stages [ stage . id ]
43
- } )
44
- if ( levelComplete ) {
45
- progress . levels [ level . id ] = true
46
- } else if ( ! position . levelId . length ) {
47
- position . levelId = level . id
48
- }
49
- }
50
- // set tutorial progress
51
- progress . complete = tutorial . version . levels . every ( ( level : G . Level ) => {
52
- return progress . levels [ level . id ]
53
- } )
54
-
55
- return assign ( {
56
- tutorial,
57
- progress,
58
- position,
59
- } )
60
- } ,
7
+ continueTutorial : assign ( {
8
+ tutorial : ( context : CR . MachineContext , event : CR . MachineEvent ) => {
9
+ return event . payload . tutorial
10
+ } ,
11
+ progress : ( context : CR . MachineContext , event : CR . MachineEvent ) => {
12
+ return event . payload . progress
13
+ } ,
14
+ position : ( context : CR . MachineContext , event : CR . MachineEvent ) => {
15
+ return event . payload . position
16
+ } ,
17
+ } ) ,
61
18
setTutorial : assign ( {
62
19
tutorial : ( context : CR . MachineContext , event : CR . MachineEvent ) : any => {
63
20
const { tutorial} = event . payload
@@ -144,6 +101,8 @@ export default {
144
101
// @ts -ignore
145
102
updateStepProgress : assign ( {
146
103
progress : ( context : CR . MachineContext , event : CR . MachineEvent ) : CR . Progress => {
104
+ console . log ( 'updateStepProgress' )
105
+ console . log ( JSON . stringify ( event ) )
147
106
// update progress by tracking completed
148
107
const currentProgress : CR . Progress = context . progress
149
108
0 commit comments