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

Commit3894427

Browse files
committed
remove stages from files
1 parentbc922a5 commit3894427

File tree

9 files changed

+29
-132
lines changed

9 files changed

+29
-132
lines changed

‎src/channel/state/Position.ts

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import * as G from 'typings/graphql'
33

44
constdefaultValue:CR.Position={
55
levelId:'',
6-
stageId:'',
76
stepId:'',
87
}
98

@@ -31,7 +30,7 @@ class Position {
3130
returnthis.value
3231
}
3332

34-
const{levels}=tutorial.version
33+
const{levels}=tutorial.version.data
3534

3635
constlastLevelIndex:number|undefined=levels.findIndex((l:G.Level)=>!progress.levels[l.id])
3736
// TODO: consider all levels complete as progress.complete
@@ -40,15 +39,7 @@ class Position {
4039
}
4140
constcurrentLevel:G.Level=levels[lastLevelIndex]
4241

43-
const{stages}=currentLevel
44-
45-
constlastStageIndex:number|undefined=stages.findIndex((s:G.Stage)=>!progress.stages[s.id])
46-
if(lastStageIndex>=stages.length){
47-
thrownewError('Error setting progress stage')
48-
}
49-
constcurrentStage:G.Stage=stages[lastStageIndex]
50-
51-
const{steps}=currentStage
42+
const{steps}=currentLevel
5243

5344
constlastStepIndex:number|undefined=steps.findIndex((s:G.Step)=>!progress.steps[s.id])
5445
if(lastStepIndex>=steps.length){
@@ -60,7 +51,6 @@ class Position {
6051

6152
this.value={
6253
levelId:currentLevel.id,
63-
stageId:currentStage.id,
6454
stepId:currentStep.id,
6555
}
6656
returnthis.value

‎typings/context.d.ts

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,18 @@
11
import*asCRfrom'./index'
22

3-
exportinterfaceStepextendsExclude<CR.TutorialStep,'actions'>{
4-
status:{
5-
complete:boolean
6-
active:boolean
7-
}
3+
interfaceProgressStatus{
4+
active:boolean
5+
complete:boolean
86
}
97

10-
exportinterfaceReceivedEvent{
11-
data:CR.Action
8+
exportinterfaceStepextendsExclude<CR.TutorialStep,'actions'>{
9+
status:ProgressStatus
1210
}
1311

14-
exportinterfaceStageStepStatus{
15-
active:boolean
16-
complete:boolean
12+
exportinterfaceReceivedEvent{
13+
data:CR.Action
1714
}
1815

19-
exportinterfaceStageWithStatusextendsCR.TutorialStage{
20-
status:StageStepStatus
16+
exportinterfaceLevelWithStatusextendsCR.TutorialLevel{
17+
status:ProgressStatus
2118
}

‎typings/index.d.ts

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,6 @@ import Storage from '../src/services/storage'
33
import*asGfrom'./graphql'
44

55
exportinterfaceTutorialLevel{
6-
stageList:string[]
7-
content:{
8-
title:string
9-
text:string
10-
}
11-
actions?:{
12-
setup:TutorialAction
13-
}
14-
}
15-
16-
exportinterfaceTutorialStage{
176
stepList:string[]
187
content:{
198
title:string
@@ -54,9 +43,6 @@ export interface TutorialData {
5443
levels:{
5544
[levelId:string]:TutorialLevel
5645
}
57-
stages:{
58-
[stageId:string]:TutorialStage
59-
}
6046
steps:{
6147
[stepId:string]:TutorialStep
6248
}
@@ -90,9 +76,6 @@ export interface Progress {
9076
levels:{
9177
[levelId:string]:boolean
9278
}
93-
stages:{
94-
[stageId:string]:boolean
95-
}
9679
steps:{
9780
[stepId:string]:boolean
9881
}
@@ -106,7 +89,6 @@ export interface StepProgress {
10689
// current tutorial position
10790
exportinterfacePosition{
10891
levelId:string
109-
stageId:string
11092
stepId:string
11193
complete?:boolean
11294
}
@@ -154,16 +136,15 @@ export interface MachineStateSchema {
154136
Initialize:{}
155137
Summary:{}
156138
LoadNext:{}
157-
Level:{}
158-
Stage:{
139+
Level:{
159140
states:{
160141
Load:{}
161142
Normal:{}
162143
TestRunning:{}
163144
TestPass:{}
164145
TestFail:{}
165146
StepNext:{}
166-
StageComplete:{}
147+
LevelComplete:{}
167148
}
168149
}
169150
Completed:{}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ const LevelSummaryPageContainer = (props: ContainerProps) => {
2828
thrownewError('Tutorial not found in LevelSummaryPageContainer')
2929
}
3030

31-
constlevel:G.Level|undefined=tutorial.version.levels.find((l:G.Level)=>l.id===position.levelId)
31+
constlevel:G.Level|undefined=tutorial.version.data.levels.find((l:G.Level)=>l.id===position.levelId)
3232

3333
if(!level){
3434
thrownewError('Level not found in LevelSummaryPageContainer')

‎web-app/src/services/selectors/position.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,15 @@ import * as tutorial from './tutorial'
55

66
exportconstdefaultPosition=()=>({
77
levelId:'',
8-
stageId:'',
98
stepId:''
109
})
1110

1211
exportconstinitialPosition=createSelector(
1312
tutorial.currentVersion,
1413
(version:G.TutorialVersion)=>{
1514
constposition:CR.Position={
16-
levelId:version.levels[0].id,
17-
stageId:version.levels[0].stages[0].id,
18-
stepId:version.levels[0].stages[0].steps[0].id,
15+
levelId:version.data.levels[0].id,
16+
stepId:version.data.levels[0].steps[0].id,
1917
}
2018
returnposition
2119
}
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
exportconstdefaultProgress=()=>({
22
levels:{},
3-
stages:{},
43
steps:{},
54
complete:false
65
})

‎web-app/src/services/selectors/tutorial.ts

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export const currentLevel = (context: MachineContext): G.Level => createSelector
2323
(version:G.TutorialVersion):G.Level=>{
2424
// merge in the updated position
2525
// sent with the test to ensure consistency
26-
constlevels:G.Level[]=version.levels
26+
constlevels:G.Level[]=version.data.levels
2727

2828
constlevel:G.Level|undefined=levels.find((l:G.Level)=>l.id===context.position.levelId)
2929

@@ -33,22 +33,10 @@ export const currentLevel = (context: MachineContext): G.Level => createSelector
3333
returnlevel
3434
})(context)
3535

36-
exportconstcurrentStage=(context:MachineContext):G.Stage=>createSelector(
37-
currentLevel,
38-
(level:G.Level):G.Stage=>{
39-
conststages:G.Stage[]=level.stages
40-
conststage:G.Stage|undefined=stages.find((s:G.Stage)=>s.id===context.position.stageId)
41-
if(!stage){
42-
thrownewError('No Stage found')
43-
}
44-
returnstage
45-
}
46-
)(context)
47-
4836
exportconstcurrentStep=(context:MachineContext):G.Step=>createSelector(
49-
currentStage,
50-
(stage:G.Stage):G.Step=>{
51-
conststeps:G.Step[]=stage.steps
37+
currentLevel,
38+
(level:G.Level):G.Step=>{
39+
conststeps:G.Step[]=level.steps
5240
conststep:G.Step|undefined=steps.find((s:G.Step)=>s.id===context.position.stepId)
5341
if(!step){
5442
thrownewError('No Step found')

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

Lines changed: 8 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export default {
2828
returnevent.payload.tutorial
2929
},
3030
progress:():CR.Progress=>{
31-
return{levels:{},stages:{},steps:{},complete:false}
31+
return{levels:{},steps:{},complete:false}
3232
}
3333
}),
3434
initTutorial:assign({
@@ -74,41 +74,20 @@ export default {
7474
},
7575
}),
7676
//@ts-ignore
77-
updateStagePosition:assign({
78-
position:(context:CR.MachineContext):CR.Position=>{
79-
const{position}=context
80-
81-
constlevel:G.Level=selectors.currentLevel(context)
82-
conststages:G.Stage[]=level.stages
83-
84-
conststageIndex=stages.findIndex((s:G.Stage)=>s.id===position.stageId)
85-
conststage:G.Stage=stages[stageIndex+1]
86-
87-
constnextPosition:CR.Position={
88-
...position,
89-
stageId:stage.id,
90-
stepId:stage.steps[0].id,
91-
}
92-
93-
returnnextPosition
94-
},
95-
}),
96-
//@ts-ignore
9777
updateLevelPosition:assign({
9878
position:(context:CR.MachineContext):CR.Position=>{
9979
const{position}=context
10080
constversion=selectors.currentVersion(context)
10181
// merge in the updated position
10282
// sent with the test to ensure consistency
103-
constlevels:G.Level[]=version.levels
83+
constlevels:G.Level[]=version.data.levels
10484

10585
constlevelIndex=levels.findIndex((l:G.Level)=>l.id===position.levelId)
10686
constlevel:G.Level=levels[levelIndex+1]
10787

10888
constnextPosition:CR.Position={
10989
levelId:level.id,
110-
stageId:level.stages[0].id,
111-
stepId:level.stages[0].steps[0].id,
90+
stepId:level.steps[0].id,
11291
}
11392

11493
returnnextPosition
@@ -128,19 +107,6 @@ export default {
128107
},
129108
}),
130109
//@ts-ignore
131-
updateStageProgress:assign({
132-
progress:(context:CR.MachineContext,event:CR.MachineEvent):CR.Progress=>{
133-
// update progress by tracking completed
134-
const{progress, position}=context
135-
136-
conststageId:string=position.stageId
137-
138-
progress.stages[stageId]=true
139-
140-
returnprogress
141-
},
142-
}),
143-
//@ts-ignore
144110
updatePosition:assign({
145111
position:(context:CR.MachineContext,event:CR.MachineEvent):CR.Progress=>{
146112
const{position}=event.payload
@@ -152,9 +118,8 @@ export default {
152118

153119
constversion=selectors.currentVersion(context)
154120
constlevel=selectors.currentLevel(context)
155-
conststage=selectors.currentStage(context)
156121

157-
conststeps:G.Step[]=stage.steps
122+
conststeps:G.Step[]=level.steps
158123

159124
conststepIndex=steps.findIndex((s:G.Step)=>s.id===position.stepId)
160125
conststepComplete=progress.steps[position.stepId]
@@ -168,39 +133,19 @@ export default {
168133
return{type:'NEXT_STEP',payload:{position:nextPosition}}
169134
}
170135

171-
// has next stage?
172-
173-
const{stages}=level
174-
conststageIndex=stages.findIndex((s:G.Stage)=>s.id===position.stageId)
175-
constfinalStage=(stageIndex>-1&&stageIndex===stages.length-1)
176-
consthasNextStage=(!finalStage)
177-
178-
// NEXT STAGE
179-
if(hasNextStage){
180-
constnextStage=stages[stageIndex+1]
181-
constnextPosition={
182-
levelId:position.levelId,
183-
stageId:nextStage.id,
184-
stepId:nextStage.steps[0].id,
185-
}
186-
return{type:'NEXT_STAGE',payload:{position:nextPosition}}
187-
}
188-
189136
// has next level?
190137

191-
const{levels}=version
138+
constlevels=context?.tutorial?.version.data.levels??[]
192139
constlevelIndex=levels.findIndex((l:G.Level)=>l.id===position.levelId)
193140
constfinalLevel=(levelIndex>-1&&levelIndex===levels.length-1)
194141
consthasNextLevel=(!finalLevel)
195142

196143
// NEXT LEVEL
197144
if(hasNextLevel){
198145
constnextLevel=levels[levelIndex+1]
199-
constnextStage=nextLevel.stages[0]
200146
constnextPosition={
201147
levelId:nextLevel.id,
202-
stageId:nextStage.id,
203-
stepId:nextStage.steps[0].id,
148+
stepId:nextLevel.steps[0].id,
204149
}
205150
return{type:'NEXT_LEVEL',payload:{position:nextPosition}}
206151
}
@@ -211,9 +156,9 @@ export default {
211156
stepNext:send((context:CR.MachineContext):CR.Action=>{
212157
const{position, progress}=context
213158

214-
conststage:G.Stage=selectors.currentStage(context)
159+
constlevel:G.Level=selectors.currentLevel(context)
215160

216-
const{steps}=stage
161+
const{steps}=level
217162
// TODO: verify not -1
218163
conststepIndex=steps.findIndex((s:G.Step)=>s.id===position.stepId)
219164
constfinalStep=stepIndex===steps.length-1

‎web-app/src/services/state/machine.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,9 @@ export const machine = Machine<CR.MachineContext, CR.MachineStateSchema, CR.Mach
1414
context:{
1515
env:{machineId:'',sessionId:'',token:''},
1616
tutorial:null,
17-
position:{levelId:'',stageId:'',stepId:''},
17+
position:{levelId:'',stepId:''},
1818
progress:{
1919
levels:{},
20-
stages:{},
2120
steps:{},
2221
complete:false
2322
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp