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

Commitccd088b

Browse files
committed
fix loading tutorial position
1 parent13a4499 commitccd088b

File tree

5 files changed

+13
-26
lines changed

5 files changed

+13
-26
lines changed

‎src/channel/context.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,11 @@ class Context {
1717
this.position=newPosition()
1818
this.progress=newProgress()
1919
}
20-
setTutorial(workspaceState:vscode.Memento,tutorial:G.Tutorial){
20+
publicsetTutorial=async(workspaceState:vscode.Memento,tutorial:G.Tutorial):Promise<{progress:CR.Progress,position:CR.Position}>=>{
2121
this.tutorial.set(tutorial)
22-
this.progress.setTutorial(workspaceState,tutorial)
22+
constprogress:CR.Progress=awaitthis.progress.setTutorial(workspaceState,tutorial)
23+
constposition:CR.Position=this.position.setPositionFromProgress(tutorial,progress)
24+
return{progress, position}
2325
}
2426
}
2527

‎src/channel/index.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,14 @@ class Channel implements Channel {
4949
}
5050

5151
// set tutorial
52-
constprogress:CR.Progress=awaitthis.context.progress.setTutorial(this.workspaceState,tutorial)
52+
const{position,progress}=awaitthis.context.setTutorial(this.workspaceState,tutorial)
5353

5454
if(progress.complete){
5555
// tutorial is already complete
5656
this.send({type:'NEW_TUTORIAL'})
5757
return
5858
}
5959

60-
constposition=this.context.position.get()
61-
6260
// communicate to client the tutorial & stepProgress state
6361
this.send({type:'CONTINUE_TUTORIAL',payload:{tutorial, progress, position}})
6462

‎src/channel/state/Position.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,23 +30,23 @@ class Position {
3030

3131
constlastLevelIndex:number|undefined=levels.findIndex((l:G.Level)=>progress.levels[l.id])
3232
// TODO: consider all levels complete as progress.complete
33-
if(lastLevelIndex<0&&lastLevelIndex<levels.length){
33+
if(lastLevelIndex>=levels.length){
3434
thrownewError('Error setting progress level')
3535
}
3636
constcurrentLevel:G.Level=levels[lastLevelIndex+1]
3737

3838
const{stages}=currentLevel
3939

4040
constlastStageIndex:number|undefined=stages.findIndex((s:G.Stage)=>progress.stages[s.id])
41-
if(lastStageIndex<0&&lastStageIndex<stages.length){
41+
if(lastStageIndex>=stages.length){
4242
thrownewError('Error setting progress stage')
4343
}
4444
constcurrentStage:G.Stage=stages[lastStageIndex+1]
4545

4646
const{steps}=currentStage
4747

4848
constlastStepIndex:number|undefined=steps.findIndex((s:G.Step)=>progress.steps[s.id])
49-
if(lastStepIndex<0&&lastStepIndex<steps.length){
49+
if(lastStepIndex>=steps.length){
5050
thrownewError('Error setting progress step')
5151
}
5252
constcurrentStep:G.Step=steps[lastStepIndex+1]

‎src/channel/state/Progress.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import * as vscode from 'vscode'
44

55
importStoragefrom'../../services/storage'
66

7-
constdefaultValue={
7+
constdefaultValue:CR.Progress={
88
levels:{},
99
stages:{},
1010
steps:{},
@@ -24,7 +24,7 @@ class Progress {
2424
storage:workspaceState,
2525
defaultValue,
2626
})// set value from storage
27-
this.value=awaitthis.storage.get()
27+
this.value=awaitthis.storage.get()||defaultValue
2828
returnthis.value
2929
}
3030
publicget=()=>{

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

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import*asReactfrom'react'
22
import*asCRfrom'typings'
33
import*asGfrom'typings/graphql'
4+
import*asselectorsfrom'../../../services/selectors'
45

56
importStagefrom'./Stage'
67

@@ -10,23 +11,9 @@ interface PageProps {
1011
}
1112

1213
constStageSummaryPageContainer=(props:PageProps)=>{
13-
const{tutorial,position, progress}=props.context
14+
const{ position, progress}=props.context
1415

15-
if(!tutorial){
16-
thrownewError('Tutorial not found in StageSummaryPageContainer')
17-
}
18-
19-
constlevel:G.Level|undefined=tutorial.version.levels.find((l:G.Level)=>l.id===position.levelId)
20-
21-
if(!level){
22-
thrownewError('Level not found in StageSummaryPageContainer')
23-
}
24-
25-
conststage:G.Stage|undefined=level.stages.find((s:G.Stage)=>s.id===position.stageId)
26-
27-
if(!stage){
28-
thrownewError('Stage not found in StageSummaryPageContainer')
29-
}
16+
conststage:G.Stage=selectors.currentStage(props.context)
3017

3118
constonContinue=():void=>{
3219
props.send({

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp