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

Commit693b36f

Browse files
committed
refactor alert
1 parent9d02a1a commit693b36f

File tree

16 files changed

+39
-41
lines changed

16 files changed

+39
-41
lines changed

‎lib/actions/progress.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ function completeTutorial(completed) {
4545
returnfunction(dispatch,getState){
4646
vartutorial=getState().tutorial;
4747
dispatch({type:_types_1.COMPLETE_TUTORIAL,payload:{tutorial:tutorial,completed:completed}});
48-
dispatch(alert_1.alertToggle({
48+
dispatch('ALER'({
4949
message:'Tutorial Complete',
5050
action:'PASS',
5151
}));

‎lib/actions/tutorial.js‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
var_types_1=require('./_types');
33
varprogress_1=require('./progress');
44
varroute_1=require('./route');
5+
varalert_1=require('./alert');
56
functiontutorialSet(name){
67
returnfunction(dispatch,getState){
78
vardir=getState().dir;
@@ -16,10 +17,10 @@ function tutorialUpdate(name) {
1617
varalert={
1718
message:"run `npm install --save-dev "+name+"`",
1819
action:'note',
19-
duration:4000,
20+
duration:3000,
2021
};
2122
dispatch({type:_types_1.TUTORIAL_UPDATE,payload:{name:name}});
22-
dispatch({type:_types_1.ALERT_TOGGLE,payload:{alert:alert}});
23+
dispatch(alert_1.alertToggle(alert));
2324
};
2425
}
2526
exports.tutorialUpdate=tutorialUpdate;

‎lib/components/Alert/index.js‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ var __metadata = (this && this.__metadata) || function (k, v) {
1515
};
1616
varReact=require('react');
1717
varreact_redux_1=require('react-redux');
18-
varactions_1=require('../../actions');
1918
varSnackbar_1=require('material-ui/Snackbar');
19+
varactions_1=require('../../actions');
2020
vardefaultAlert={
2121
message:'',
2222
open:false,
@@ -28,13 +28,13 @@ var Alert = (function (_super) {
2828
}
2929
Alert.prototype.render=function(){
3030
var_a=this.props,alert=_a.alert,alertToggle=_a.alertToggle;
31-
varaction=alert.action,open=alert.open,message=alert.message,duration=alert.duration;
32-
return(React.createElement(Snackbar_1.default,{className:"cr-alert "+action,open:open||false,message:message||'',action:action,autoHideDuration:duration||2000,onActionTouchTap:alertToggle,onRequestClose:alertToggle}));
31+
varaction=alert.action,message=alert.message,open=alert.open,duration=alert.duration;
32+
return(React.createElement(Snackbar_1.default,{className:"cr-alert "+action,open:open,message:message||'',action:action||'NOTE',autoHideDuration:duration||2000,onRequestClose:alertToggle}));
3333
};
3434
Alert=__decorate([
3535
react_redux_1.connect(null,function(dispatch){
3636
return{
37-
alertToggle:function(){returndispatch(actions_1.alertToggle());},
37+
alertToggle:function(){returndispatch(actions_1.alertToggle({open:false}));}
3838
};
3939
}),
4040
__metadata('design:paramtypes',[])

‎lib/reducers/alert/index.js‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,7 @@ function alertReducer(alert, action) {
2929
case_types_1.ALERT_REPLAY:
3030
returnsetAlert(current);
3131
case_types_1.ALERT_TOGGLE:
32-
vara=action.payload.alert;
33-
if(!a){
34-
return_alert;
35-
}
36-
returnsetAlert(a);
32+
returnsetAlert(action.payload.alert);
3733
default:
3834
returnalert;
3935
}

‎lib/store/index.js‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@ var redux_1 = require('redux');
33
varredux_action_thunk_1=require('redux-action-thunk');
44
varreducers_1=require('../reducers');
55
varcreateLogger=require('redux-logger');
6-
varredux_thunk_1=require('redux-thunk');
7-
varmiddlewares=[redux_action_thunk_1.ratMiddleware,redux_thunk_1.default];
8-
vardevMode=false;
6+
varmiddlewares=[redux_action_thunk_1.ratMiddleware];
7+
vardevMode=true;
98
if(devMode){
109
varlogger=createLogger();
1110
middlewares.push(logger);

‎package.json‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@
4646
"react-redux":"4.4.5",
4747
"react-tap-event-plugin":"1.0.0",
4848
"redux":"3.5.2",
49-
"redux-action-thunk":"0.1.0",
49+
"redux-action-thunk":"0.3.0",
5050
"redux-logger":"2.6.1",
51-
"redux-thunk":"^2.1.0"
51+
"redux-thunk":"2.1.0"
5252
},
5353
"scripts": {
5454
"compile":"tsc"

‎src/actions/alert.ts‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,11 @@ export function alertToggle(alert: Object): ReduxThunk.ThunkInterface {
99
exportfunctionalertReplay():Action{
1010
return{type:ALERT_REPLAY};
1111
}
12+
13+
// import {rat} from 'redux-action-thunk';
14+
//
15+
// rat.add('ALERT_TOGGLE', (dispatch, getState) => (alert) => {
16+
// dispatch({ type: 'ALERT_TOGGLE', payload: { alert }});
17+
// });
18+
//
19+
// rat.add('ALERT_REPLAY');

‎src/actions/hint.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import{HINT_SHOW,HINT_POSITION_SET}from'./_types';
1+
import{HINT_POSITION_SET}from'./_types';
22

33
exportfunctionhintPositionSet(hintPosition:number):Action{
44
return{type:HINT_POSITION_SET,payload:{ hintPosition}};

‎src/actions/index.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
export{alertToggle,alertReplay}from'./alert';
2+
// import './alert';
23
export{
34
progressLoad,completePage,completeTutorial,
45
progressPagePositionLoad

‎src/actions/progress.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export function completeTutorial(completed = true): ReduxThunk.ThunkInterface {
4545
return(dispatch,getState):void=>{
4646
const{tutorial}=getState();
4747
dispatch({type:COMPLETE_TUTORIAL,payload:{ tutorial, completed}});
48-
dispatch(alertToggle({
48+
dispatch('ALER'({
4949
message:'Tutorial Complete',
5050
action:'PASS',
5151
}));

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp