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

Commit1091125

Browse files
committed
move init & summary into start
1 parent288af75 commit1091125

File tree

6 files changed

+41
-47
lines changed

6 files changed

+41
-47
lines changed

‎typings/index.d.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,15 +66,14 @@ export interface MachineStateSchema {
6666
Error:{}
6767
NewOrContinue:{}
6868
SelectTutorial:{}
69+
LoadTutorial:{}
70+
Summary:{}
6971
ContinueTutorial:{}
7072
}
7173
}
7274
Tutorial:{
7375
states:{
74-
Initialize:{}
75-
Summary:{}
7676
LoadNext:{}
77-
Error:{}
7877
Level:{
7978
states:{
8079
Load:{}

‎web-app/src/Routes.tsx

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,15 @@ import LevelSummaryPage from './containers/Tutorial/LevelPage'
1111

1212
constRoutes=()=>{
1313
const{ context, send, Router, Route}=useRouter()
14-
// TODO refactor for typescript to understand send & context passed into React.cloneElement's
1514
return(
1615
<Workspace>
1716
<Router>
1817
<Routepath={['Start.Startup','Start.Authenticate','Start.NewOrContinue']}>
1918
<LoadingPagetext="Launching..."context={context}/>
2019
</Route>
20+
<Routepath="Start.Initialize">
21+
<LoadingPagetext="Initializing..."context={context}/>
22+
</Route>
2123
<Routepath={'Start.Error'}>
2224
<div>Something went wrong wrong</div>
2325
</Route>
@@ -27,17 +29,11 @@ const Routes = () => {
2729
<Routepath="Start.ContinueTutorial">
2830
<ContinuePagesend={send}context={context}/>
2931
</Route>
30-
<Routepath={'Tutorial.Error'}>
31-
<div>Something went wrong wrong</div>
32-
</Route>
33-
<Routepath="Tutorial.Initialize">
34-
<LoadingPagetext="Initializing..."context={context}/>
32+
<Routepath="Start.Summary">
33+
<OverviewPagesend={send}context={context}/>
3534
</Route>
3635
<Routepath="Tutorial.LoadNext">
37-
<LoadingPagetext="Loading..."context={context}/>
38-
</Route>
39-
<Routepath="Tutorial.Summary">
40-
<OverviewPagesend={send}context={context}/>
36+
<LoadingPagetext="Loading Level..."context={context}/>
4137
</Route>
4238
<Routepath="Tutorial.Level">
4339
<LevelSummaryPagesend={send}context={context}/>

‎web-app/src/components/Router/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ const useRouter = () => {
3939
constchildArray=React.Children.toArray(children)
4040
for(constchildofchildArray){
4141
// match path
42+
//@ts-ignore
4243
const{ path}=child.props
4344
letpathMatch
4445
if(typeofpath==='string'){

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

Lines changed: 30 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -67,21 +67,46 @@ export const createMachine = (options: any) => {
6767
target:'ContinueTutorial',
6868
actions:['continueTutorial'],
6969
},
70-
NEW_TUTORIAL:{
71-
target:'SelectTutorial',
72-
},
70+
NEW_TUTORIAL:'SelectTutorial',
7371
},
7472
},
7573
SelectTutorial:{
7674
onEntry:['clearStorage'],
7775
id:'start-new-tutorial',
7876
on:{
7977
TUTORIAL_START:{
80-
target:'#tutorial',
78+
target:'LoadTutorial',
8179
actions:['newTutorial'],
8280
},
8381
},
8482
},
83+
// TODO move Initialize into New Tutorial setup
84+
LoadTutorial:{
85+
invoke:{
86+
src:services.loadTutorial,
87+
onDone:{
88+
target:'Summary',
89+
actions:assign({
90+
tutorial:(context,event)=>event.data,
91+
}),
92+
},
93+
onError:{
94+
target:'Error',
95+
actions:assign({
96+
error:(context,event)=>event.data,
97+
}),
98+
},
99+
},
100+
},
101+
Summary:{
102+
on:{
103+
BACK:'SelectTutorial',
104+
LOAD_TUTORIAL:{
105+
target:'#tutorial',
106+
actions:['initPosition','initTutorial'],
107+
},
108+
},
109+
},
85110
ContinueTutorial:{
86111
on:{
87112
TUTORIAL_START:{
@@ -95,7 +120,7 @@ export const createMachine = (options: any) => {
95120
},
96121
Tutorial:{
97122
id:'tutorial',
98-
initial:'Initialize',
123+
initial:'LoadNext',
99124
on:{
100125
// track commands
101126
COMMAND_START:{
@@ -112,33 +137,6 @@ export const createMachine = (options: any) => {
112137
},
113138
},
114139
states:{
115-
// TODO move Initialize into New Tutorial setup
116-
Initialize:{
117-
invoke:{
118-
src:services.initialize,
119-
onDone:{
120-
target:'Summary',
121-
actions:assign({
122-
tutorial:(context,event)=>event.data,
123-
}),
124-
},
125-
onError:{
126-
target:'Error',
127-
actions:assign({
128-
error:(context,event)=>event.data,
129-
}),
130-
},
131-
},
132-
},
133-
Error:{},
134-
Summary:{
135-
on:{
136-
LOAD_TUTORIAL:{
137-
target:'Level',
138-
actions:['initPosition','initTutorial'],
139-
},
140-
},
141-
},
142140
LoadNext:{
143141
id:'tutorial-load-next',
144142
onEntry:['loadNext'],
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
export{authenticate}from'./authenticate'
2-
export{initialize}from'./initialize'
2+
export{loadTutorial}from'./loadTutorial'

‎web-app/src/services/state/services/initialize.tsrenamed to‎web-app/src/services/state/services/loadTutorial.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ interface TutorialDataVariables {
1313
// version: string
1414
}
1515

16-
exportasyncfunctioninitialize(context:CR.MachineContext):Promise<any>{
16+
exportasyncfunctionloadTutorial(context:CR.MachineContext):Promise<any>{
1717
// setup test runner and git
1818
if(!context.tutorial){
1919
consterror=newError('Tutorial not available to load')

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp