Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitaad32f3

Browse files
committed
fix issues with stepNext
Signed-off-by: shmck <shawn.j.mckay@gmail.com>
1 parentbd96f17 commitaad32f3

File tree

3 files changed

+12
-38
lines changed

3 files changed

+12
-38
lines changed

‎web-app/src/services/state/actions/context.ts

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -34,28 +34,7 @@ export const initPosition = assign({
3434

3535
exportconstupdateStepPosition=assign({
3636
position:(context:T.MachineContext,event:T.MachineEvent):any=>{
37-
const{ position}=context
38-
// merge in the updated position
39-
// sent with the test to ensure consistency
40-
constlevel:TT.Level=selectors.currentLevel(context)
41-
conststeps:TT.Step[]=level.steps
42-
43-
// final step now completed
44-
if(steps[steps.length-1].id===position.stepId){
45-
return{ ...position,complete:true}
46-
}
47-
48-
conststepIndex=steps.findIndex((s:TT.Step)=>s.id===position.stepId)
49-
50-
conststep:TT.Step=steps[stepIndex+1]
51-
52-
constnextPosition:T.Position={
53-
...position,
54-
stepId:step.id,
55-
complete:false,
56-
}
57-
58-
returnnextPosition
37+
returnevent.payload.position
5938
},
6039
})
6140

‎web-app/src/services/state/actions/utils/stepNext.test.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,6 @@ describe('stepNext', () => {
2929
it('should LOAD_NEXT_STEP when there is another step',()=>{
3030
constposition={levelId:'1',stepId:'1.2',complete:false}
3131
constresult=getStepNext(position,level)
32-
expect(result).toEqual({
33-
type:'LOAD_NEXT_STEP',
34-
payload:{
35-
step:level.steps[1],
36-
},
37-
})
38-
})
39-
it('should LOAD_NEXT_STEP when there is another step but no more',()=>{
40-
constposition={levelId:'1',stepId:'1.3',complete:false}
41-
constresult=getStepNext(position,level)
4232
expect(result).toEqual({
4333
type:'LOAD_NEXT_STEP',
4434
payload:{

‎web-app/src/services/state/actions/utils/stepNext.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,22 @@
11
import*asTfrom'typings'
22
import*asTTfrom'typings/tutorial'
3+
importloggerfrom'../../../../services/logger'
34

45
constgetStepNext=(position:T.Position,level:TT.Level):T.Action=>{
6+
logger('getStepNext position',position)
57
const{ steps}=level
68

79
if(steps.length){
810
conststepIndex=steps.findIndex((s:TT.Step)=>s.id===position.stepId)
9-
constnextStep=steps[stepIndex]
10-
return{
11-
type:'LOAD_NEXT_STEP',
12-
payload:{
13-
step:nextStep,
14-
},
11+
constfinalStepIndex=steps.length-1
12+
if(stepIndex<finalStepIndex){
13+
constnextStep=steps[stepIndex+1]
14+
return{
15+
type:'LOAD_NEXT_STEP',
16+
payload:{
17+
step:nextStep,
18+
},
19+
}
1520
}
1621
}
1722
return{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp