diff options
-rw-r--r-- | src/web/js/actions/MenuActions.js | 17 | ||||
-rw-r--r-- | src/web/js/actions/MiddlePanelActions.js | 16 | ||||
-rw-r--r-- | src/web/js/components/Menu.react.js | 21 | ||||
-rw-r--r-- | src/web/js/components/MiddlePanel.react.js | 19 |
4 files changed, 18 insertions, 55 deletions
diff --git a/src/web/js/actions/MenuActions.js b/src/web/js/actions/MenuActions.js index bf039fd1..4266c207 100644 --- a/src/web/js/actions/MenuActions.js +++ b/src/web/js/actions/MenuActions.js @@ -15,25 +15,12 @@ var MenuActions = { }); }); }, - setFilterAll: function() { + setFilter: function(filter) { JarrDispatcher.dispatch({ type: ActionTypes.MENU_FILTER, - filter: 'all', + filter: filter, }); }, - setFilterUnread: function() { - JarrDispatcher.dispatch({ - type: ActionTypes.MENU_FILTER, - filter: 'unread', - }); - }, - setFilterError: function() { - JarrDispatcher.dispatch({ - type: ActionTypes.MENU_FILTER, - filter: 'error', - }); - }, - }; module.exports = MenuActions; diff --git a/src/web/js/actions/MiddlePanelActions.js b/src/web/js/actions/MiddlePanelActions.js index 7c956e85..47a9958c 100644 --- a/src/web/js/actions/MiddlePanelActions.js +++ b/src/web/js/actions/MiddlePanelActions.js @@ -73,22 +73,10 @@ var MiddlePanelActions = { filter_id: feed_id, }); }, - setFilterAll: function() { + setFilter: function(filter) { reloadIfNecessaryAndDispatch({ type: ActionTypes.MIDDLE_PANEL_FILTER, - filter: 'all', - }); - }, - setFilterUnread: function() { - reloadIfNecessaryAndDispatch({ - type: ActionTypes.MIDDLE_PANEL_FILTER, - filter: 'unread', - }); - }, - setFilterLiked: function() { - reloadIfNecessaryAndDispatch({ - type: ActionTypes.MIDDLE_PANEL_FILTER, - filter: 'liked', + filter: filter, }); }, changeRead: function(category_id, feed_id, article_id, new_value){ diff --git a/src/web/js/components/Menu.react.js b/src/web/js/components/Menu.react.js index 3e5f4156..09250706 100644 --- a/src/web/js/components/Menu.react.js +++ b/src/web/js/components/Menu.react.js @@ -121,34 +121,27 @@ var MenuFilter = React.createClass({ var error_button = null; if (this.state.feed_in_error) { error_button = (<Button active={this.state.filter == "error"} - onMouseDown={MenuActions.setFilterError} + onMouseDown={() => this.setFilter("error")} bsSize="small" bsStyle="warning">Error</Button> ); } return (<Row className="show-grid"> <ButtonGroup> <Button active={this.state.filter == "all"} - onMouseDown={MenuActions.setFilterAll} + onMouseDown={() => this.setFilter("all")} bsSize="small">All</Button> <Button active={this.state.filter == "unread"} - onMouseDown={MenuActions.setFilterUnread} + onMouseDown={() => this.setFilter("unread")} bsSize="small">Unread</Button> {error_button} </ButtonGroup> </Row> ); }, - componentDidMount: function() { - MenuStore.addChangeListener(this._onChange); - }, - componentWillUnmount: function() { - MenuStore.removeChangeListener(this._onChange); - }, - _onChange: function() { - var datas = MenuStore.getAll(); - this.setState({filter: datas.filter, - feed_in_error: datas.feed_in_error}); - }, + setFilter: function(filter) { + this.setState({filter: filter}); + MenuActions.setFilter(filter); + } }); var Menu = React.createClass({ diff --git a/src/web/js/components/MiddlePanel.react.js b/src/web/js/components/MiddlePanel.react.js index 741af5e9..e0ea8110 100644 --- a/src/web/js/components/MiddlePanel.react.js +++ b/src/web/js/components/MiddlePanel.react.js @@ -64,27 +64,22 @@ var MiddlePanelFilter = React.createClass({ return (<Row className="show-grid"> <ButtonGroup> <Button active={this.state.filter == "all"} - onMouseDown={MiddlePanelActions.setFilterAll} + onMouseDown={() => this.setFilter("all")} bsSize="small">All</Button> <Button active={this.state.filter == "unread"} - onMouseDown={MiddlePanelActions.setFilterUnread} + onMouseDown={() => this.setFilter("unread")} bsSize="small">Unread</Button> <Button active={this.state.filter == "liked"} - onMouseDown={MiddlePanelActions.setFilterLiked} + onMouseDown={() => this.setFilter("liked")} bsSize="small">Liked</Button> </ButtonGroup> </Row> ); }, - componentDidMount: function() { - MiddlePanelStore.addChangeListener(this._onChange); - }, - componentWillUnmount: function() { - MiddlePanelStore.removeChangeListener(this._onChange); - }, - _onChange: function() { - this.setState({filter: MiddlePanelStore._datas.filter}); - }, + setFilter: function(filter) { + this.setState({filter: filter}); + MiddlePanelActions.setFilter(filter); + } }); var MiddlePanel = React.createClass({ |