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

Commit814f633

Browse files
authored
Merge pull requestcoderoad#8 from ShMcK/fix/workflow
Fix/workflow
2 parentsa12f254 +e7008f6 commit814f633

File tree

7 files changed

+57
-28
lines changed

7 files changed

+57
-28
lines changed

‎src/editor/ReactWebView.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class ReactWebView {
3131
console.log('webview loaded')
3232
}
3333

34-
publicasynccreateOrShow(column:number):Promise<void>{
34+
publiccreateOrShow(column:number):void{
3535
// If we already have a panel, show it.
3636
// Otherwise, create a new panel.
3737
if(this.panel&&this.panel.webview){
@@ -40,7 +40,6 @@ class ReactWebView {
4040
}else{
4141
console.log('make new panel')
4242
this.panel=this.createWebviewPanel(column)
43-
4443
}
4544
}
4645

‎src/editor/commands/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ export const createCommands = ({ context, machine, storage, git, position }: Cre
4343
// open React webview
4444
[COMMANDS.OPEN_WEBVIEW]:(column:number=vscode.ViewColumn.One)=>{
4545
webview.createOrShow(column);
46+
setTimeout(()=>{
47+
machine.send('WEBVIEW_INITIALIZED')
48+
},2000)
4649
},
4750
// launch a new tutorial
4851
// NOTE: may be better to move into action as logic is primarily non-vscode

‎src/state/actions/index.ts

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -78,23 +78,31 @@ export default {
7878
console.log('ACTION: tutorialLoad.progress')
7979
returncurrentProgress
8080
},
81-
position(){
81+
position(context:any):CR.Position{
8282
console.log('ACTION: tutorialLoad.position')
8383
if(!currentTutorial){
8484
thrownewError('No Tutorial loaded')
8585
}
8686
const{ data}=currentTutorial
87-
88-
constlevelId=data.summary.levelList[0]
89-
conststageId=data.levels[levelId].stageList[0]
90-
conststepId=data.stages[stageId].stepList[0]
87+
constlevelId=data.summary.levelList.find((id:string)=>!currentProgress.levels[id])
88+
if(!levelId){
89+
thrownewError('No level found on position load')
90+
}
91+
conststageId=data.levels[levelId].stageList.find((id:string)=>!currentProgress.stages[id])
92+
if(!stageId){
93+
thrownewError('No stage found on position load')
94+
}
95+
conststepId=data.stages[stageId].stepList.find((id:string)=>!currentProgress.steps[id])
96+
if(!stepId){
97+
thrownewError('No step found on position load')
98+
}
9199

92100
constposition={
93101
levelId,
94102
stageId,
95-
stepId,
103+
stepId
96104
}
97-
105+
console.log('position',position)
98106
returnposition
99107
}
100108
}),
@@ -120,6 +128,7 @@ export default {
120128
[context.position.stepId]:true,
121129
}
122130
}
131+
console.log('progress update',nextProgress)
123132
storage.setProgress(nextProgress)
124133
returnnextProgress
125134
}
@@ -134,6 +143,7 @@ export default {
134143
[context.position.stageId]:true,
135144
}
136145
}
146+
console.log('progress update',nextProgress)
137147
storage.setProgress(nextProgress)
138148
returnnextProgress
139149
}
@@ -148,6 +158,7 @@ export default {
148158
[context.position.levelId]:true,
149159
}
150160
}
161+
console.log('progress update',nextProgress)
151162
storage.setProgress(nextProgress)
152163
returnnextProgress
153164

@@ -160,20 +171,24 @@ export default {
160171
...context.progress,
161172
complete:true,
162173
}
174+
console.log('progress update',nextProgress)
163175
storage.setProgress(nextProgress)
164176
returnnextProgress
165177
}
166178
}),
167179
stepLoadNext:assign({
168-
position:(context:any)=>{
180+
position:(context:any):CR.Position=>{
169181
const{ data, position}=context
170182
const{ stepList}=data.stages[position.stageId]
171183
constcurrentStepIndex=stepList.indexOf(position.stepId)
172184
constnextStepId=stepList[currentStepIndex+1]
173-
return{
185+
186+
constnextPosition={
174187
...context.position,
175188
stepId:nextStepId,
176189
}
190+
console.log('position update',nextPosition)
191+
returnnextPosition
177192
}
178193
}),
179194
loadLevel(){

‎src/state/guards/index.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,14 @@ import * as CR from 'typings'
22

33
exportdefault{
44
hasNextStep:(context:CR.MachineContext):boolean=>{
5-
const{ data, position}=context
5+
const{ data, position, progress}=context
66
conststeps=data.stages[position.stageId].stepList
7-
consthasNext=steps[steps.length-1]!==position.stepId
8-
console.log('GUARD: hasNextStep',hasNext)
9-
returnhasNext
7+
// isn't final step yet
8+
if(steps[steps.length-1]!==position.stepId){
9+
returntrue
10+
}
11+
// final step is not yet complete
12+
return!progress.steps[position.stepId]
1013
},
1114
hasNextStage:(context:CR.MachineContext):boolean=>{
1215
const{ data, position}=context

‎src/state/machine.ts

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ export const machine = Machine<
2020
initial:'Initial',
2121
states:{
2222
Initial:{
23-
after:{
24-
2000:'Startup'
23+
on:{
24+
WEBVIEW_INITIALIZED:'Startup'
2525
}
2626
},
2727
Startup:{
@@ -50,7 +50,7 @@ export const machine = Machine<
5050
ContinueTutorial:{
5151
onEntry:['tutorialContinue'],
5252
on:{
53-
TUTORIAL_START:'#tutorial-load-next'
53+
TUTORIAL_START:'#tutorial-load-current'
5454
}
5555
},
5656
}
@@ -66,6 +66,13 @@ export const machine = Machine<
6666
0:'Summary'
6767
}
6868
},
69+
LoadCurrent:{
70+
id:'tutorial-load-current',
71+
// TODO: verify current is not complete
72+
after:{
73+
0:'Stage'
74+
},
75+
},
6976
LoadNext:{
7077
id:'tutorial-load-next',
7178
onEntry:['tutorialLoadNext'],
@@ -120,14 +127,9 @@ export const machine = Machine<
120127
TestPass:{
121128
onEntry:['testPass','stepComplete'],
122129
after:{
123-
1000:{
124-
target:'StepNext',
125-
cond:'hasNextStep',
126-
}
127-
},
128-
on:{
129-
NEXT:'StageComplete',
130+
1000:'StepNext',
130131
},
132+
131133
},
132134
TestFail:{
133135
onEntry:['testFail'],
@@ -138,8 +140,14 @@ export const machine = Machine<
138140
StepNext:{
139141
onEntry:['stepLoadNext'],
140142
after:{
141-
0:'Normal'
142-
}
143+
0:[{
144+
target:'Normal',
145+
cond:'hasNextStep',
146+
actions:['stepLoadCommits']
147+
},{
148+
target:'StageComplete'
149+
}]
150+
},
143151
},
144152
StageComplete:{
145153
onEntry:'stageComplete',

‎typings/index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ export interface MachineStateSchema {
148148
states:{
149149
Initialize:{}
150150
Summary:{}
151+
LoadCurrent:{}
151152
LoadNext:{}
152153
Level:{}
153154
Stage:{

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const StagePage = (props: PageProps) => {
2525
...data.steps[stepId],
2626
status:{
2727
// flag progressed steps as complete
28-
complete:progress.steps[stepId]||false,
28+
complete:progress.stages[stageId]||false,
2929
// set active step to active
3030
active:position.stepId===stepId,
3131
},

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp