@@ -32,6 +32,7 @@ export default {
32
32
const canContinue = ! ! ( tutorial && progress && hasGit && hasGitRemote )
33
33
34
34
if ( canContinue ) {
35
+ // continue
35
36
currentTutorial = tutorial
36
37
currentProgress = progress
37
38
}
@@ -41,6 +42,7 @@ export default {
41
42
async tutorialLaunch ( ) {
42
43
// TODO: add selection of tutorial id
43
44
const tutorial : CR . Tutorial = await api ( { resource : 'getTutorial' , params : { id : '1' } } )
45
+ currentTutorial = tutorial
44
46
console . log ( 'api' )
45
47
console . log ( tutorial )
46
48
vscode . commands . executeCommand ( 'coderoad.tutorial_launch' , tutorial )
@@ -49,6 +51,19 @@ export default {
49
51
vscode . commands . executeCommand ( 'coderoad.tutorial_setup' , currentTutorial )
50
52
vscode . commands . executeCommand ( 'coderoad.open_webview' , vscode . ViewColumn . Two )
51
53
} ,
54
+ initializeNewTutorial : assign ( {
55
+ position : ( context : any ) : CR . Position => {
56
+ const { data } = context
57
+ const levelId = data . summary . levelList [ 0 ]
58
+ const stageId = data . levels [ levelId ] . stageList [ 0 ]
59
+ const stepId = data . stages [ stageId ] . stepList [ 0 ]
60
+ return {
61
+ levelId,
62
+ stageId,
63
+ stepId
64
+ }
65
+ }
66
+ } ) ,
52
67
tutorialContinue : assign ( {
53
68
// load initial data, progress & position
54
69
data ( ) : CR . TutorialData {
@@ -149,7 +164,22 @@ export default {
149
164
return nextProgress
150
165
}
151
166
} ) ,
152
- stepLoadNext ( ) {
153
- console . log ( "LOAD NEXT STEP" )
167
+ stepLoadNext : assign ( {
168
+ position : ( context : any ) => {
169
+ const { data, position } = context
170
+ const { stepList } = data . stages [ position . stageId ]
171
+ const currentStepIndex = stepList . indexOf ( position . stepId )
172
+ const nextStepId = stepList [ currentStepIndex + 1 ]
173
+ return {
174
+ ...context . position ,
175
+ stepId : nextStepId ,
176
+ }
177
+ }
178
+ } ) ,
179
+ loadLevel ( ) {
180
+ console . log ( 'loadLevel' )
181
+ } ,
182
+ loadStage ( ) {
183
+ console . log ( 'loadStage' )
154
184
}
155
185
}
0 commit comments