diff options
author | François Schmidts <francois.schmidts@gmail.com> | 2016-01-26 22:43:18 +0100 |
---|---|---|
committer | François Schmidts <francois.schmidts@gmail.com> | 2016-01-26 23:47:57 +0100 |
commit | df8d1742d7e8ac6a7d238799dda05557fd0d17a9 (patch) | |
tree | becc78a3f23e77c5e8b126d8080ca83214830dc7 /src/web/js/components | |
parent | ressucitating old js (diff) | |
download | newspipe-df8d1742d7e8ac6a7d238799dda05557fd0d17a9.tar.gz newspipe-df8d1742d7e8ac6a7d238799dda05557fd0d17a9.tar.bz2 newspipe-df8d1742d7e8ac6a7d238799dda05557fd0d17a9.zip |
optim on filter, not rerendering
Diffstat (limited to 'src/web/js/components')
-rw-r--r-- | src/web/js/components/Menu.react.js | 21 | ||||
-rw-r--r-- | src/web/js/components/MiddlePanel.react.js | 19 |
2 files changed, 14 insertions, 26 deletions
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({ |