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

Commita7a7a94

Browse files
committed
fix up step progress
1 parentda942ac commita7a7a94

File tree

3 files changed

+50
-10
lines changed

3 files changed

+50
-10
lines changed

‎web-app/src/containers/Tutorial/StagePage/index.tsx

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ interface PageProps {
1212
constStageSummaryPageContainer=(props:PageProps)=>{
1313
const{ tutorial, position, progress}=props.context
1414

15-
conststage:G.Stage=tutorial.version.levels.find((l:G.Level)=>l.id===position.levelId).stages.find((s:G.Stage)=>s.id===position.stageId)
15+
conststage:G.Stage=tutorial.version
16+
.levels.find((l:G.Level)=>l.id===position.levelId)
17+
.stages.find((s:G.Stage)=>s.id===position.stageId)
1618

1719
constonContinue=():void=>{
1820
props.send({
@@ -32,7 +34,7 @@ const StageSummaryPageContainer = (props: PageProps) => {
3234
})
3335
}
3436

35-
stage.steps.forEach((step:G.Step)=>{
37+
stage.steps.map((step:G.Step)=>{
3638
if(step.id===position.stepId){
3739
step.status='ACTIVE'
3840
}elseif(progress.steps[step.id]){
@@ -46,3 +48,26 @@ const StageSummaryPageContainer = (props: PageProps) => {
4648
}
4749

4850
exportdefaultStageSummaryPageContainer
51+
52+
/*
53+
const formattedStage = {
54+
...stage,
55+
steps: stage.steps.map((step: G.Step) => {
56+
if (step.id === position.stepId) {
57+
return {
58+
...step,
59+
status: 'ACTIVE'
60+
}
61+
} else if (progress.steps[step.id]) {
62+
return {
63+
...step,
64+
status: 'COMPLETE'
65+
}
66+
} else {
67+
return {
68+
...step,
69+
status: 'INCOMPLETE'
70+
}
71+
}
72+
})
73+
*/

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

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,23 @@ export default {
4242
//@ts-ignore
4343
stepLoadNext:assign({
4444
position:(context:CR.MachineContext,event:CR.MachineEvent):CR.Position=>{
45-
constcurrentPosition:CR.Position=context.position
45+
constposition:CR.Position=context.position
4646
// merge in the updated position
4747
// sent with the test to ensure consistency
48-
console.log('should calculate next step')
48+
conststeps:G.Step[]=context.tutorial.version
49+
.levels.find((l:G.Level)=>l.id===position.levelId)
50+
.stages.find((s:G.Stage)=>s.id===position.stageId)
51+
.steps
52+
53+
conststepIndex=steps.findIndex((s:G.Step)=>s.id===position.stepId)
54+
console.log('step index',stepIndex)
55+
conststep:G.Step=steps[stepIndex+1]
56+
57+
console.log('step load next',step.id,position.stepId)
4958

5059
return{
51-
...currentPosition,
60+
...position,
61+
stepId:step.id
5262
}
5363
},
5464
})

‎web-app/src/services/state/guards/index.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,30 @@ export default {
66
hasNextStep:(context:CR.MachineContext):boolean=>{
77
const{tutorial, position}=context
88
// TODO: protect against errors
9-
conststeps:G.Step[]=tutorial.version.levels.find((l:G.Level)=>l.id===position.levelId).stages.find((s:G.Stage)=>s.id===position.stageId).steps
9+
conststeps:G.Step[]=tutorial.version
10+
.levels.find((l:G.Level)=>l.id===position.levelId)
11+
.stages.find((s:G.Stage)=>s.id===position.stageId)
12+
.steps
1013

1114
// TODO: verify not -1
12-
return!(steps.indexOf(position.stepId)===steps.length-1)
15+
return!(steps.findIndex((s:G.Step)=>s.id===position.stepId)===steps.length-1)
1316
},
1417
hasNextStage:(context:CR.MachineContext):boolean=>{
1518
const{tutorial, position}=context
1619
// TODO: protect against errors
17-
conststages:G.Stage[]=tutorial.version.levels.find((l:G.Level)=>l.id===position.levelId).stages
20+
conststages:G.Stage[]=tutorial.version
21+
.levels.find((l:G.Level)=>l.id===position.levelId)
22+
.stages
1823

1924
// TODO: verify not -1
20-
return!(stages.indexOf(position.stageId)===stages.length-1)
25+
return!(stages.findIndex((s:G.Stage)=>s.id===position.stageId)===stages.length-1)
2126
},
2227
hasNextLevel:(context:CR.MachineContext):boolean=>{
2328
const{tutorial, position}=context
2429
// TODO: protect against errors
2530
constlevels:G.Level[]=tutorial.version.levels
2631

2732
// TODO: verify not -1
28-
return!(levels.indexOf(position.levelId)===levels.length-1)
33+
return!(levels.findIndex((l:G.Level)=>l.id===position.levelId)===levels.length-1)
2934
},
3035
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp