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

Commit1f8d8bd

Browse files
authored
Merge pull requestcoderoad#253 from coderoad/fix/simplify-states
merge env_get and load_tutorial steps
2 parentsa597b10 +f55ef73 commit1f8d8bd

File tree

6 files changed

+40
-47
lines changed

6 files changed

+40
-47
lines changed

‎src/channel/index.ts

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class Channel implements Channel {
4848
// console.log(`ACTION: ${actionType}`)
4949

5050
switch(actionType){
51-
case'EDITOR_ENV_GET':
51+
case'EDITOR_STARTUP':
5252
// check if a workspace is open, otherwise nothing works
5353
constnoActiveWorksapce=!environment.WORKSPACE_ROOT.length
5454
if(noActiveWorksapce){
@@ -65,23 +65,18 @@ class Channel implements Channel {
6565
this.send({type:'NO_WORKSPACE',payload:{ error}})
6666
return
6767
}
68-
this.send({
69-
type:'ENV_LOAD',
70-
payload:{
71-
env:{
72-
machineId:vscode.env.machineId,
73-
sessionId:vscode.env.sessionId,
74-
},
75-
},
76-
})
77-
return
78-
// continue from tutorial from local storage
79-
case'EDITOR_TUTORIAL_LOAD':
68+
69+
constenv={
70+
machineId:vscode.env.machineId,
71+
sessionId:vscode.env.sessionId,
72+
}
73+
74+
// continue from tutorial from local storage
8075
consttutorial:TT.Tutorial|null=this.context.tutorial.get()
8176

8277
// new tutorial
8378
if(!tutorial||!tutorial.id){
84-
this.send({type:'START_NEW_TUTORIAL'})
79+
this.send({type:'START_NEW_TUTORIAL',payload:{ env}})
8580
return
8681
}
8782

@@ -90,13 +85,14 @@ class Channel implements Channel {
9085

9186
if(progress.complete){
9287
// tutorial is already complete
93-
this.send({type:'START_NEW_TUTORIAL'})
88+
this.send({type:'TUTORIAL_ALREADY_COMPLETE',payload:{ env}})
9489
return
9590
}
9691
// communicate to client the tutorial & stepProgress state
97-
this.send({type:'LOAD_STORED_TUTORIAL',payload:{ tutorial, progress, position}})
92+
this.send({type:'LOAD_STORED_TUTORIAL',payload:{env,tutorial, progress, position}})
9893

9994
return
95+
10096
// clear tutorial local storage
10197
case'TUTORIAL_CLEAR':
10298
// clear current progress/position/tutorial

‎typings/index.d.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ export interface MachineStateSchema {
6565
Setup:{
6666
states:{
6767
Startup:{}
68-
LoadStoredTutorial:{}
6968
Start:{}
7069
ValidateSetup:{}
7170
SelectTutorial:{}

‎web-app/src/Routes.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const Routes = () => {
2424
<Workspace>
2525
<Router>
2626
{/* Setup */}
27-
<Routepath={['Setup.Startup','Setup.LoadStoredTutorial','Setup.ValidateSetup']}>
27+
<Routepath={['Setup.Startup','Setup.ValidateSetup']}>
2828
<LoadingPagetext="Launching..."/>
2929
</Route>
3030
<Routepath="Setup.Start">

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import onError from '../../../services/sentry/onError'
66

77
constcontextActions:ActionFunctionMap<T.MachineContext,T.MachineEvent>={
88
//@ts-ignore
9-
setEnv:assign({
9+
setStart:assign({
1010
env:(context:T.MachineContext,event:T.MachineEvent)=>{
1111
return{
1212
...context.env,
@@ -16,6 +16,12 @@ const contextActions: ActionFunctionMap<T.MachineContext, T.MachineEvent> = {
1616
}),
1717
//@ts-ignore
1818
storeContinuedTutorial:assign({
19+
env:(context:T.MachineContext,event:T.MachineEvent)=>{
20+
return{
21+
...context.env,
22+
...event.payload.env,
23+
}
24+
},
1925
tutorial:(context:T.MachineContext,event:T.MachineEvent)=>{
2026
returnevent.payload.tutorial
2127
},

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

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,9 @@ import * as TT from 'typings/tutorial'
33
import*asselectorsfrom'../../selectors'
44

55
exportdefault(editorSend:any)=>({
6-
loadEnv():void{
6+
startup():void{
77
editorSend({
8-
type:'EDITOR_ENV_GET',
9-
})
10-
},
11-
loadStoredTutorial():void{
12-
// send message to editor to see if there is existing tutorial progress
13-
// in local storage on the editor
14-
editorSend({
15-
type:'EDITOR_TUTORIAL_LOAD',
8+
type:'EDITOR_STARTUP',
169
})
1710
},
1811
configureNewTutorial(context:CR.MachineContext){

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

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -34,37 +34,27 @@ export const createMachine = (options: any) => {
3434
initial:'Startup',
3535
states:{
3636
Startup:{
37-
onEntry:['loadEnv'],
37+
onEntry:['startup'],
3838
onExit:['clearError'],
3939
on:{
40-
ENV_LOAD:{
41-
target:'LoadStoredTutorial',
42-
actions:['setEnv'],
43-
},
4440
NO_WORKSPACE:{
4541
actions:['setError'],
4642
},
4743
REQUEST_WORKSPACE:{
4844
actions:'requestWorkspaceSelect',
4945
},
50-
},
51-
},
52-
LoadStoredTutorial:{
53-
onEntry:['loadStoredTutorial'],
54-
on:{
5546
LOAD_STORED_TUTORIAL:{
5647
target:'Start',
5748
actions:['storeContinuedTutorial'],
5849
},
59-
START_NEW_TUTORIAL:'Start',
60-
},
61-
},
62-
Start:{
63-
on:{
64-
NEW_TUTORIAL:'ValidateSetup',
65-
CONTINUE_TUTORIAL:{
66-
target:'#tutorial-level',
67-
actions:['continueConfig'],
50+
START_NEW_TUTORIAL:{
51+
target:'Start',
52+
actions:['setStart'],
53+
},
54+
// TODO: handle completed tutorial differently
55+
TUTORIAL_ALREADY_COMPLETE:{
56+
target:'Start',
57+
actions:['setStart'],
6858
},
6959
},
7060
},
@@ -83,6 +73,15 @@ export const createMachine = (options: any) => {
8373
SETUP_VALIDATED:'SelectTutorial',
8474
},
8575
},
76+
Start:{
77+
on:{
78+
NEW_TUTORIAL:'ValidateSetup',
79+
CONTINUE_TUTORIAL:{
80+
target:'#tutorial-level',
81+
actions:['continueConfig'],
82+
},
83+
},
84+
},
8685
SelectTutorial:{
8786
onEntry:['clearStorage'],
8887
id:'select-new-tutorial',

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp