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

Commit74159d5

Browse files
authored
Merge pull request#34 from ShMcK/fix/continue
Fix/continue
2 parentse3ace75 +5750bc2 commit74159d5

File tree

9 files changed

+70
-23
lines changed

9 files changed

+70
-23
lines changed

‎src/actions/tutorialConfig.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,19 @@ import * as G from 'typings/graphql'
22
import*asvscodefrom'vscode'
33
import*asgitfrom'../services/git'
44

5-
consttutorialConfig=async(tutorial:G.Tutorial)=>{
5+
interfaceTutorialConfigParams{
6+
tutorial:G.Tutorial,
7+
alreadyConfigured?:boolean
8+
}
9+
10+
consttutorialConfig=async({tutorial, alreadyConfigured}:TutorialConfigParams)=>{
11+
if(!alreadyConfigured){
12+
// setup git, add remote
13+
awaitgit.initIfNotExists()
614

7-
//setup git, addremote
8-
awaitgit.initIfNotExists()
9-
awaitgit.setupRemote(tutorial.repo.uri)
15+
//TODO: ifremote not already set
16+
awaitgit.setupRemote(tutorial.repo.uri)
17+
}
1018

1119
// TODO: allow multiple coding languages in a tutorial
1220
constlanguage=tutorial.codingLanguage.toLowerCase()

‎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: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,25 @@ 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':
7171
consttutorialData=action.payload.tutorial
7272
this.context.setTutorial(this.workspaceState,tutorialData)
73-
tutorialConfig(tutorialData)
73+
tutorialConfig({
74+
tutorial:tutorialData
75+
})
76+
return
77+
case'EDITOR_TUTORIAL_CONTINUE_CONFIG':
78+
consttutorialContinue:G.Tutorial|null=this.context.tutorial.get()
79+
if(!tutorialContinue){
80+
thrownewError('Invalid tutorial to continue')
81+
}
82+
tutorialConfig({
83+
tutorial:tutorialContinue,
84+
alreadyConfigured:true
85+
})
7486
return
7587
case'EDITOR_SYNC_PROGRESS':
7688
// sync client progress on server

‎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: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export default {
1111
type:'EDITOR_TUTORIAL_LOAD',
1212
})
1313
},
14+
// TODO: syncProgress unused
1415
syncProgress(context:CR.MachineContext){
1516
// sync progress in editor local storage for persistence
1617
channel.editorSend({
@@ -23,6 +24,7 @@ export default {
2324
initializeTutorial(context:CR.MachineContext,event:CR.MachineEvent){
2425
// setup test runner and git
2526
const{tutorial}=event.data.payload
27+
2628
if(!tutorial){
2729
thrownewError('Invalid tutorial for tutorial config')
2830
}
@@ -32,6 +34,11 @@ export default {
3234
payload:{tutorial},
3335
})
3436
},
37+
continueConfig(){
38+
channel.editorSend({
39+
type:'EDITOR_TUTORIAL_CONTINUE_CONFIG',
40+
})
41+
},
3542
testStart(context:CR.MachineContext,event:CR.MachineEvent){
3643
console.log('EDITOR: TEST_RUN')
3744
const{stepId}=event.payload
@@ -75,7 +82,7 @@ export default {
7582
})
7683
}
7784
},
78-
clearStorage(){
85+
clearStorage():void{
7986
channel.editorSend({type:'TUTORIAL_CLEAR'})
8087
}
8188
}

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

Lines changed: 8 additions & 3 deletions
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:{
@@ -50,7 +50,10 @@ export const machine = Machine<CR.MachineContext, CR.MachineStateSchema, CR.Mach
5050
},
5151
ContinueTutorial:{
5252
on:{
53-
TUTORIAL_START:'#tutorial-stage',
53+
TUTORIAL_START:{
54+
target:'#tutorial-stage',
55+
actions:['continueConfig'],
56+
},
5457
TUTORIAL_SELECT:'SelectTutorial'
5558
},
5659
},
@@ -60,6 +63,7 @@ export const machine = Machine<CR.MachineContext, CR.MachineStateSchema, CR.Mach
6063
id:'tutorial',
6164
initial:'Initialize',
6265
states:{
66+
// TODO: move Initialize into New Tutorial setup
6367
Initialize:{
6468
invoke:{
6569
id:'loadTutorial',
@@ -155,6 +159,7 @@ export const machine = Machine<CR.MachineContext, CR.MachineStateSchema, CR.Mach
155159
}
156160
},
157161
StageComplete:{
162+
onEntry:['syncProgress'],
158163
on:{
159164
STAGE_NEXT:'#tutorial-load-next',
160165
},
@@ -163,7 +168,7 @@ export const machine = Machine<CR.MachineContext, CR.MachineStateSchema, CR.Mach
163168
},
164169
Completed:{
165170
id:'completed-tutorial',
166-
onEntry:['userTutorialComplete'],
171+
onEntry:['syncProgress','userTutorialComplete'],
167172
on:{
168173
SELECT_TUTORIAL:{
169174
target:'#start-new-tutorial',

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp