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

Commit23082a4

Browse files
committed
working version without progress
Signed-off-by: shmck <shawn.j.mckay@gmail.com>
1 parentaad32f3 commit23082a4

File tree

8 files changed

+24
-16
lines changed

8 files changed

+24
-16
lines changed

‎src/environment.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export type Env = 'test' | 'local' | 'development' | 'production'
1111
exportconstNODE_ENV:Env=process.env.NODE_ENV||'development'
1212

1313
// toggle logging in development
14-
exportconstLOG=true
14+
exportconstLOG=false
1515

1616
// error logging tool
1717
exportconstINSTRUMENTATION_KEY='6ff37c76-72f3-48e3-a1b9-d5636f519b7b'

‎web-app/src/Routes.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ const Routes = () => {
2121
}
2222

2323
logger(`ROUTE:${route}`)
24+
logger(`POSITION:${JSON.stringify(context.position)}`)
2425

2526
return(
2627
<Routerroute={route}>

‎web-app/src/environment.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
// validate .env
2-
constrequiredKeys=['REACT_APP_TUTORIAL_LIST_URL']
3-
for(constrequiredofrequiredKeys){
4-
if(!process.env[required]){
5-
thrownewError(`Missing Environmental Variable:${required}`)
6-
}
7-
}
2+
//const requiredKeys = ['REACT_APP_TUTORIAL_LIST_URL']
3+
//for (const required of requiredKeys) {
4+
// if (!process.env[required]) {
5+
// throw new Error(`Missing Environmental Variable: ${required}`)
6+
// }
7+
//}
88

99
exportconstDEBUG:boolean=(process.env.REACT_APP_DEBUG||'').toLowerCase()==='true'
1010
exportconstVERSION:string=process.env.VERSION||'unknown'

‎web-app/src/services/logger/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import{LOG}from'../../environment'
22

3-
exporttypeLog=string|object|null
3+
exporttypeLog=string|object|number|null
44

55
constlogger=(...messages:Log[]):void=>{
66
if(!LOG){

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { assign, send } from 'xstate'
44
import*asselectorsfrom'../../selectors'
55
importgetStepNextfrom'./utils/stepNext'
66
importgetNextfrom'./utils/getNext'
7+
importloggerfrom'services/logger'
78

89
exportconstsetStart=assign({
910
env:(context:T.MachineContext,event:T.MachineEvent)=>{
@@ -34,6 +35,7 @@ export const initPosition = assign({
3435

3536
exportconstupdateStepPosition=assign({
3637
position:(context:T.MachineContext,event:T.MachineEvent):any=>{
38+
logger('updateStepPosition',event)
3739
returnevent.payload.position
3840
},
3941
})
@@ -54,8 +56,6 @@ export const loadNext = send(
5456
exportconststepNext=send(
5557
(context:T.MachineContext):T.Action=>{
5658
constlevel:TT.Level=selectors.currentLevel(context)
57-
console.log(`STEP_NEXT:${JSON.stringify(context.position)}`)
58-
console.log(`STEP NEXT LEVEL${JSON.stringify(level)}`)
5959
returngetStepNext(context.position,level)
6060
},
6161
)

‎web-app/src/services/state/actions/utils/stepNext.test.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,17 @@ const level: TT.Level = {
2626
}
2727

2828
describe('stepNext',()=>{
29-
it('should LOAD_NEXT_STEP when there is another step',()=>{
29+
it('should LOAD_NEXT_STEP when there is another step (1)',()=>{
30+
constposition={levelId:'1',stepId:'1.1',complete:true}
31+
constresult=getStepNext(position,level)
32+
expect(result).toEqual({
33+
type:'LOAD_NEXT_STEP',
34+
payload:{
35+
step:level.steps[1],
36+
},
37+
})
38+
})
39+
it('should LOAD_NEXT_STEP when there is another step (2)',()=>{
3040
constposition={levelId:'1',stepId:'1.2',complete:false}
3141
constresult=getStepNext(position,level)
3242
expect(result).toEqual({
@@ -36,7 +46,6 @@ describe('stepNext', () => {
3646
},
3747
})
3848
})
39-
4049
it('should LEVEL_COMPLETE when there are no steps',()=>{
4150
constposition={levelId:'1',stepId:null,complete:false}
4251
constresult=getStepNext(position,{ ...level,steps:[]})

‎web-app/src/services/state/actions/utils/stepNext.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@ import * as TT from 'typings/tutorial'
33
importloggerfrom'../../../../services/logger'
44

55
constgetStepNext=(position:T.Position,level:TT.Level):T.Action=>{
6-
logger('getStepNext position',position)
76
const{ steps}=level
8-
97
if(steps.length){
108
conststepIndex=steps.findIndex((s:TT.Step)=>s.id===position.stepId)
119
constfinalStepIndex=steps.length-1
@@ -14,7 +12,7 @@ const getStepNext = (position: T.Position, level: TT.Level): T.Action => {
1412
return{
1513
type:'LOAD_NEXT_STEP',
1614
payload:{
17-
step:nextStep,
15+
position:{levelId:position.levelId,stepId:nextStep.id,complete:false},
1816
},
1917
}
2018
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ export const createMachine = (options: any) => {
198198
on:{
199199
LOAD_NEXT_STEP:{
200200
target:'Normal',
201-
actions:['loadStep'],
201+
actions:['loadStep','updateStepPosition'],
202202
},
203203
LEVEL_COMPLETE:'LevelComplete',
204204
},

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp