Skip to content

Commit b6a15d8

Browse files
committed
replace load-current with load-next
1 parent 0f1255a commit b6a15d8

File tree

3 files changed

+19
-23
lines changed

3 files changed

+19
-23
lines changed

src/state/guards/index.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ export default {
55
const { data, position, progress } = context
66
const steps = data.stages[position.stageId].stepList
77
// isn't final step yet
8-
const hasNext = !!position.stepId && (steps[steps.length - 1] !== position.stepId) || !progress.stages[position.stageId]
8+
const stageIncomplete = !progress.stages[position.stageId]
9+
const hasNext = stageIncomplete && (!!position.stepId && (steps[steps.length - 1] !== position.stepId))
910
console.log('GUARD: hasNextStep', hasNext)
1011
return hasNext
1112
},

src/state/machine.ts

+17-21
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export const machine = (dispatch: CR.EditorDispatch) =>
4747
ContinueTutorial: {
4848
onEntry: ['tutorialContinue'],
4949
on: {
50-
TUTORIAL_START: '#tutorial-load-current',
50+
TUTORIAL_START: '#tutorial-load-next',
5151
},
5252
},
5353
},
@@ -57,7 +57,7 @@ export const machine = (dispatch: CR.EditorDispatch) =>
5757
initial: 'Initialize',
5858
onEntry: ['tutorialSetup'],
5959
on: {
60-
WEBVIEW_INITIALIZED: '#tutorial-load-current'
60+
WEBVIEW_INITIALIZED: '#tutorial-load-next'
6161
},
6262
states: {
6363
Initialize: {
@@ -66,28 +66,24 @@ export const machine = (dispatch: CR.EditorDispatch) =>
6666
0: 'Summary',
6767
},
6868
},
69-
LoadCurrent: {
70-
id: 'tutorial-load-current',
71-
// TODO: verify current is not complete
72-
after: {
73-
0: 'Stage',
74-
},
75-
},
7669
LoadNext: {
7770
id: 'tutorial-load-next',
7871
after: {
79-
0: [
80-
{
81-
target: 'Stage',
82-
cond: 'hasNextStage',
83-
},
84-
{
85-
target: 'Level',
86-
cond: 'hasNextLevel',
87-
},
88-
{
89-
target: '#completed-tutorial',
90-
},
72+
0: [{
73+
target: 'Stage',
74+
cond: 'hasNextStep',
75+
},
76+
{
77+
target: 'Stage',
78+
cond: 'hasNextStage',
79+
},
80+
{
81+
target: 'Level',
82+
cond: 'hasNextLevel',
83+
},
84+
{
85+
target: '#completed-tutorial',
86+
},
9187
],
9288
},
9389
},

typings/index.d.ts

-1
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,6 @@ export interface MachineStateSchema {
148148
states: {
149149
Initialize: {}
150150
Summary: {}
151-
LoadCurrent: {}
152151
LoadNext: {}
153152
Level: {}
154153
Stage: {

0 commit comments

Comments
 (0)