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

Commit87f8460

Browse files
committed
refactor SET_PACKAGE & PAGE_POSITION_LOAD
1 parent216a791 commit87f8460

File tree

16 files changed

+51
-48
lines changed

16 files changed

+51
-48
lines changed

‎lib/actions/_types.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ exports.COMPLETE_TUTORIAL = 'COMPLETE_TUTORIAL';
66
exports.DEVTOOLS_TOGGLE='DEVTOOLS_TOGGLE';
77
exports.HINT_POSITION_SET='HINT_POSITION_SET';
88
exports.HINT_SHOW='HINT_SHOW';
9-
exports.PACKAGE_SET='PACKAGE_SET';
109
exports.PAGE_SET='PAGE_SET';
11-
exports.PAGE_POSITION_LOAD='POSITION_LOAD';
1210
exports.PAGE_POSITION_SET='POSITION_SET';
1311
exports.PROGRESS_LOAD='PROGRESS_LOAD';
12+
exports.PROGRESS_PAGE_POSITION_LOAD='PROGRESS_PAGE_POSITION_LOAD';
1413
exports.QUIT='QUIT';
1514
exports.ROUTE_SET='ROUTE_SET';
1615
exports.TEST_SAVE='TEST_SAVE';
16+
exports.SETUP_PACKAGE='SETUP_PACKAGE';
1717
exports.SETUP_VERIFY='SETUP_VERIFY';
1818
exports.TEST_COMPLETE='TEST_COMPLETE';
1919
exports.TEST_RESULT='TEST_RESULT';

‎lib/actions/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,19 @@ var progress_1 = require('./progress');
66
exports.progressLoad=progress_1.progressLoad;
77
exports.completePage=progress_1.completePage;
88
exports.completeTutorial=progress_1.completeTutorial;
9+
exports.progressPagePositionLoad=progress_1.progressPagePositionLoad;
910
varhint_1=require('./hint');
1011
exports.hintShow=hint_1.hintShow;
1112
exports.hintPositionSet=hint_1.hintPositionSet;
1213
varpage_1=require('./page');
1314
exports.pageSet=page_1.pageSet;
1415
exports.pageNext=page_1.pageNext;
15-
exports.pagePositionLoad=page_1.pagePositionLoad;
1616
exports.pagePositionSet=page_1.pagePositionSet;
1717
varroute_1=require('./route');
1818
exports.routeSet=route_1.routeSet;
1919
varsetup_1=require('./setup');
2020
exports.setupVerify=setup_1.setupVerify;
21+
exports.setupPackage=setup_1.setupPackage;
2122
vartest_1=require('./test');
2223
exports.testRun=test_1.testRun;
2324
exports.testComplete=test_1.testComplete;

‎lib/actions/page.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,6 @@ function pageSet(pagePosition) {
2929
};
3030
}
3131
exports.pageSet=pageSet;
32-
functionpagePositionLoad(){
33-
returnfunction(dispatch,getState){
34-
varprogress=getState().progress;
35-
dispatch({type:_types_1.PAGE_POSITION_LOAD,payload:{progress:progress}});
36-
};
37-
}
38-
exports.pagePositionLoad=pagePositionLoad;
3932
functionpagePositionSet(pagePosition){
4033
return{type:_types_1.PAGE_POSITION_SET,payload:{pagePosition:pagePosition}};
4134
}

‎lib/actions/progress.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
"use strict";
22
var_types_1=require('./_types');
3-
varpage_1=require('./page');
3+
functionprogressPagePositionLoad(){
4+
returnfunction(dispatch,getState){
5+
varprogress=getState().progress;
6+
dispatch({type:_types_1.PROGRESS_PAGE_POSITION_LOAD,payload:{progress:progress}});
7+
};
8+
}
9+
exports.progressPagePositionLoad=progressPagePositionLoad;
410
functionprogressLoad(){
511
returnfunction(dispatch,getState){
612
vartutorial=getState().tutorial;
713
dispatch({type:_types_1.PROGRESS_LOAD,payload:{tutorial:tutorial}});
8-
dispatch(page_1.pagePositionLoad());
14+
dispatch(progressPagePositionLoad());
915
};
1016
}
1117
exports.progressLoad=progressLoad;

‎lib/actions/setup.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
"use strict";
22
var_types_1=require('./_types');
3-
varpackage_1=require('./package');
43
functionsetupVerify(){
54
returnfunction(dispatch,getState){
6-
dispatch(package_1.packageSet());
5+
dispatch(setupPackage());
76
var_a=getState(),dir=_a.dir,packageJson=_a.packageJson;
87
dispatch({type:_types_1.SETUP_VERIFY,payload:{dir:dir,packageJson:packageJson}});
98
};
109
}
1110
exports.setupVerify=setupVerify;
11+
functionsetupPackage(){
12+
returnfunction(dispatch,getState){
13+
vardir=getState().dir;
14+
dispatch({type:_types_1.SETUP_PACKAGE,payload:{dir:dir}});
15+
};
16+
}
17+
exports.setupPackage=setupPackage;

‎lib/reducers/package-json/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ var exists_1 = require('../../services/exists');
66
functionpackageJsonReducer(pj,action){
77
if(pj===void0){pj=null;}
88
switch(action.type){
9-
case_types_1.PACKAGE_SET:
9+
case_types_1.SETUP_PACKAGE:
1010
vardir=action.payload.dir;
1111
varpathToPackageJson=path_1.join(dir,'package.json');
1212
if(exists_1.fileExists(pathToPackageJson)){

‎lib/reducers/page-position/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ var _types_1 = require('../../actions/_types');
33
functionpagePositionReducer(pagePosition,action){
44
if(pagePosition===void0){pagePosition=0;}
55
switch(action.type){
6-
case_types_1.PAGE_POSITION_LOAD:
6+
case_types_1.PROGRESS_PAGE_POSITION_LOAD:
77
varpages=action.payload.progress.pages;
88
varfirstFail=pages.indexOf(false);
99
returnfirstFail<0 ?pages.length-1 :firstFail;

‎src/actions/_types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ export const COMPLETE_TUTORIAL = 'COMPLETE_TUTORIAL';
55
exportconstDEVTOOLS_TOGGLE='DEVTOOLS_TOGGLE';
66
exportconstHINT_POSITION_SET='HINT_POSITION_SET';
77
exportconstHINT_SHOW='HINT_SHOW';
8-
exportconstPACKAGE_SET='PACKAGE_SET';
98
exportconstPAGE_SET='PAGE_SET';
10-
exportconstPAGE_POSITION_LOAD='POSITION_LOAD';
119
exportconstPAGE_POSITION_SET='POSITION_SET';
1210
exportconstPROGRESS_LOAD='PROGRESS_LOAD';
11+
exportconstPROGRESS_PAGE_POSITION_LOAD='PROGRESS_PAGE_POSITION_LOAD';
1312
exportconstQUIT='QUIT';
1413
exportconstROUTE_SET='ROUTE_SET';
1514
exportconstTEST_SAVE='TEST_SAVE';
15+
exportconstSETUP_PACKAGE='SETUP_PACKAGE';
1616
exportconstSETUP_VERIFY='SETUP_VERIFY';
1717
exportconstTEST_COMPLETE='TEST_COMPLETE';
1818
exportconstTEST_RESULT='TEST_RESULT';

‎src/actions/index.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
export{alertToggle,alertReplay}from'./alert';
22
export{
3-
progressLoad,completePage,completeTutorial
3+
progressLoad,completePage,completeTutorial,
4+
progressPagePositionLoad
45
}from'./progress';
56
export{hintShow,hintPositionSet}from'./hint';
6-
export{pageSet,pageNext,pagePositionLoad,pagePositionSet}from'./page';
7+
export{pageSet,pageNext,pagePositionSet}from'./page';
78
export{routeSet}from'./route';
8-
export{setupVerify}from'./setup';
9+
export{setupVerify,setupPackage}from'./setup';
910
export{
1011
testRun,testComplete,testResult,testSave
1112
}from'./test';

‎src/actions/package.ts

Lines changed: 0 additions & 8 deletions
This file was deleted.

‎src/actions/page.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import{
2-
ROUTE_SET,PAGE_SET,PAGE_POSITION_SET,PAGE_POSITION_LOAD
2+
ROUTE_SET,PAGE_SET,PAGE_POSITION_SET
33
}from'./_types';
44
importconfigTaskTestsfrom'./config-task-tests';
55

@@ -32,13 +32,6 @@ export function pageSet(pagePosition = 0): ReduxThunk.ThunkInterface {
3232
};
3333
}
3434

35-
exportfunctionpagePositionLoad():ReduxThunk.ThunkInterface{
36-
return(dispatch,getState):void=>{
37-
const{progress}=getState();
38-
dispatch({type:PAGE_POSITION_LOAD,payload:{ progress}});
39-
};
40-
}
41-
4235
exportfunctionpagePositionSet(pagePosition:CR.PagePosition):Action{
4336
return{type:PAGE_POSITION_SET,payload:{ pagePosition}};
4437
}

‎src/actions/progress.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
11
import{
2-
PROGRESS_LOAD,COMPLETE_PAGE,COMPLETE_TUTORIAL
2+
PROGRESS_PAGE_POSITION_LOAD,PROGRESS_LOAD,COMPLETE_PAGE,COMPLETE_TUTORIAL
33
}from'./_types';
4-
import{pagePositionLoad}from'./page';
4+
5+
exportfunctionprogressPagePositionLoad():ReduxThunk.ThunkInterface{
6+
return(dispatch,getState):void=>{
7+
const{progress}=getState();
8+
dispatch({type:PROGRESS_PAGE_POSITION_LOAD,payload:{ progress}});
9+
};
10+
}
511

612
exportfunctionprogressLoad():ReduxThunk.ThunkInterface{
713
return(dispatch,getState):void=>{
814
const{tutorial}=getState();
915
dispatch({type:PROGRESS_LOAD,payload:{ tutorial}});
1016
// call pagePositionLoad after progress loads
11-
dispatch(pagePositionLoad());
17+
dispatch(progressPagePositionLoad());
1218
};
1319
}
1420

‎src/actions/setup.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
1-
import{SETUP_VERIFY}from'./_types';
2-
import{packageSet}from'./package';
1+
import{SETUP_VERIFY,SETUP_PACKAGE}from'./_types';
32

43
exportfunctionsetupVerify():ReduxThunk.ThunkInterface{
54
return(dispatch,getState):void=>{
6-
dispatch(packageSet());
5+
dispatch(setupPackage());
76
const{dir, packageJson}=getState();
87
dispatch({type:SETUP_VERIFY,payload:{ dir, packageJson}});
98
};
109
}
10+
11+
exportfunctionsetupPackage():ReduxThunk.ThunkInterface{
12+
return(dispatch,getState):void=>{
13+
const{dir}=getState();
14+
dispatch({type:SETUP_PACKAGE,payload:{ dir}});
15+
};
16+
}

‎src/reducers/package-json/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import{PACKAGE_SET}from'../../actions/_types';
1+
import{SETUP_PACKAGE}from'../../actions/_types';
22
import{join}from'path';
33
import{readFileSync}from'fs';
44
import{fileExists}from'../../services/exists';
@@ -8,7 +8,7 @@ export default function packageJsonReducer(
88
):PackageJson{
99
switch(action.type){
1010

11-
casePACKAGE_SET:
11+
caseSETUP_PACKAGE:
1212
const{dir}=action.payload;
1313
constpathToPackageJson=join(dir,'package.json');
1414
if(fileExists(pathToPackageJson)){

‎src/reducers/page-position/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import{
2-
PAGE_SET,PAGE_POSITION_SET,PAGE_POSITION_LOAD
2+
PAGE_SET,PAGE_POSITION_SET,PROGRESS_PAGE_POSITION_LOAD
33
}from'../../actions/_types';
44

55
exportdefaultfunctionpagePositionReducer(
66
pagePosition=0,action:Action
77
):CR.PagePosition{
88
switch(action.type){
99

10-
casePAGE_POSITION_LOAD:
10+
casePROGRESS_PAGE_POSITION_LOAD:
1111
constpages=action.payload.progress.pages;
1212
constfirstFail=pages.indexOf(false);
1313
returnfirstFail<0 ?pages.length-1 :firstFail;

‎tsconfig.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@
5656
"src/actions/config-task-tests.ts",
5757
"src/actions/hint.ts",
5858
"src/actions/index.ts",
59-
"src/actions/package.ts",
6059
"src/actions/page.ts",
6160
"src/actions/progress.ts",
6261
"src/actions/route.ts",

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp