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

Commit19d819c

Browse files
committed
ensure clearing of old progress on new
1 parente3ace75 commit19d819c

File tree

8 files changed

+31
-16
lines changed

8 files changed

+31
-16
lines changed

‎src/channel/context.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ class Context {
2323
constposition:CR.Position=this.position.setPositionFromProgress(tutorial,progress)
2424
return{progress, position}
2525
}
26+
publicreset=()=>{
27+
this.tutorial.reset()
28+
this.progress.reset()
29+
this.position.reset()
30+
}
2631
}
2732

2833
exportdefaultContext

‎src/channel/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ class Channel implements Channel {
6464
// clear tutorial local storage
6565
case'TUTORIAL_CLEAR':
6666
// clear current progress/position/tutorial
67-
this.context=newContext(this.workspaceState)
67+
this.context.reset()
6868
return
6969
// configure test runner, language, git
7070
case'EDITOR_TUTORIAL_CONFIG':

‎src/channel/state/Position.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,27 @@
11
import*asCRfrom'typings'
22
import*asGfrom'typings/graphql'
33

4+
constdefaultValue:CR.Position={
5+
levelId:'',
6+
stageId:'',
7+
stepId:'',
8+
}
9+
410
// position
511
classPosition{
612
privatevalue:CR.Position
713
constructor(){
8-
this.value={
9-
levelId:'',
10-
stageId:'',
11-
stepId:'',
12-
}
14+
this.value=defaultValue
1315
}
1416
publicget=()=>{
1517
returnthis.value
1618
}
1719
publicset=(value:CR.Position)=>{
1820
this.value=value
1921
}
22+
publicreset=()=>{
23+
this.value=defaultValue
24+
}
2025
// calculate the current position based on the saved progress
2126
publicsetPositionFromProgress=(tutorial:G.Tutorial,progress:CR.Progress):CR.Position=>{
2227

‎src/channel/state/Progress.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,15 @@ class Progress {
3232
}
3333
publicset=(value:CR.Progress)=>{
3434
this.value=value
35-
if(this.storage){
36-
this.storage.set(value)
35+
if(!this.storage){
36+
thrownewError('Tutorial storage not found')
3737
}
38+
this.storage.set(value)
3839
returnthis.value
3940
}
41+
publicreset=()=>{
42+
this.set(defaultValue)
43+
}
4044
publicsetStepComplete=(stepId:string):CR.Progress=>{
4145
constnext=this.value
4246
next.steps[stepId]=true

‎src/channel/state/Tutorial.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,13 @@ class Tutorial {
1919
this.value=value
2020
})
2121
}
22-
publicget=()=>{
23-
returnthis.value
24-
}
25-
publicset=(value:G.Tutorial)=>{
22+
publicget=()=>this.value
23+
publicset=(value:G.Tutorial|null)=>{
2624
this.value=value
25+
this.storage.set(value)
26+
}
27+
publicreset=()=>{
28+
this.set(null)
2729
}
2830
}
2931

‎src/editor/ReactWebView.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ class ReactWebView {
3131
privatechannel:Channel
3232

3333
publicconstructor({extensionPath, workspaceState}:ReactWebViewProps){
34-
console.log(`extPath${extensionPath}`)
3534
this.extensionPath=extensionPath
3635

3736
// Create and show a new webview panel
@@ -73,7 +72,7 @@ class ReactWebView {
7372
this.channel=newChannel({
7473
workspaceState,
7574
postMessage:(action:Action):Thenable<boolean>=>{
76-
console.log(`postMessage${JSON.stringify(action)}`)
75+
//console.log(`postMessage ${JSON.stringify(action)}`)
7776
returnthis.panel.webview.postMessage(action)
7877
}
7978
})

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ export default {
7575
})
7676
}
7777
},
78-
clearStorage(){
78+
clearStorage():void{
7979
channel.editorSend({type:'TUTORIAL_CLEAR'})
8080
}
8181
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@ export const machine = Machine<CR.MachineContext, CR.MachineStateSchema, CR.Mach
3535
},
3636
NEW_TUTORIAL:{
3737
target:'SelectTutorial',
38-
actions:['clearStorage']
3938
}
4039
},
4140
},
4241
SelectTutorial:{
42+
onEntry:['clearStorage'],
4343
id:'start-new-tutorial',
4444
on:{
4545
TUTORIAL_START:{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp