summaryrefslogtreecommitdiffstats
path: root/web/react/components/sidebar_right.jsx
diff options
context:
space:
mode:
authorChristopher Speller <crspeller@gmail.com>2015-11-19 08:08:28 -0500
committerChristopher Speller <crspeller@gmail.com>2015-11-19 08:08:28 -0500
commit5f848b74793f679772473a3b5b2ab247bcc927a9 (patch)
tree1d53e4c9dd6351e7a56c0f67dcf3bac4c38a8369 /web/react/components/sidebar_right.jsx
parent0dbbdaa45e639d508a4e75933a42ac4c313202d2 (diff)
parent70c957d4546016ff2d981d4e1704699b008d1ca5 (diff)
downloadchat-5f848b74793f679772473a3b5b2ab247bcc927a9.tar.gz
chat-5f848b74793f679772473a3b5b2ab247bcc927a9.tar.bz2
chat-5f848b74793f679772473a3b5b2ab247bcc927a9.zip
Merge pull request #1457 from hmhealey/plt729
PLT-729 Added search button to mobile header
Diffstat (limited to 'web/react/components/sidebar_right.jsx')
-rw-r--r--web/react/components/sidebar_right.jsx27
1 files changed, 20 insertions, 7 deletions
diff --git a/web/react/components/sidebar_right.jsx b/web/react/components/sidebar_right.jsx
index ab558ad0f..8d16057fc 100644
--- a/web/react/components/sidebar_right.jsx
+++ b/web/react/components/sidebar_right.jsx
@@ -7,10 +7,6 @@ var SearchStore = require('../stores/search_store.jsx');
var PostStore = require('../stores/post_store.jsx');
var Utils = require('../utils/utils.jsx');
-function getStateFromStores() {
- return {search_visible: SearchStore.getSearchResults() != null, post_right_visible: PostStore.getSelectedPost() != null, is_mention_search: SearchStore.getIsMentionSearch()};
-}
-
export default class SidebarRight extends React.Component {
constructor(props) {
super(props);
@@ -19,19 +15,29 @@ export default class SidebarRight extends React.Component {
this.onSelectedChange = this.onSelectedChange.bind(this);
this.onSearchChange = this.onSearchChange.bind(this);
+ this.onShowSearch = this.onShowSearch.bind(this);
this.doStrangeThings = this.doStrangeThings.bind(this);
- this.state = getStateFromStores();
+ this.state = this.getStateFromStores();
+ }
+ getStateFromStores() {
+ return {
+ search_visible: SearchStore.getSearchResults() != null,
+ post_right_visible: PostStore.getSelectedPost() != null,
+ is_mention_search: SearchStore.getIsMentionSearch()
+ };
}
componentDidMount() {
SearchStore.addSearchChangeListener(this.onSearchChange);
PostStore.addSelectedPostChangeListener(this.onSelectedChange);
+ SearchStore.addShowSearchListener(this.onShowSearch);
this.doStrangeThings();
}
componentWillUnmount() {
SearchStore.removeSearchChangeListener(this.onSearchChange);
PostStore.removeSelectedPostChangeListener(this.onSelectedChange);
+ SearchStore.removeShowSearchListener(this.onShowSearch);
}
componentWillUpdate() {
PostStore.jumpPostsViewSidebarOpen();
@@ -64,18 +70,25 @@ export default class SidebarRight extends React.Component {
this.doStrangeThings();
}
onSelectedChange(fromSearch) {
- var newState = getStateFromStores(fromSearch);
+ var newState = this.getStateFromStores(fromSearch);
newState.from_search = fromSearch;
if (!Utils.areObjectsEqual(newState, this.state)) {
this.setState(newState);
}
}
onSearchChange() {
- var newState = getStateFromStores();
+ var newState = this.getStateFromStores();
if (!Utils.areObjectsEqual(newState, this.state)) {
this.setState(newState);
}
}
+ onShowSearch() {
+ if (!this.state.search_visible) {
+ this.setState({
+ search_visible: true
+ });
+ }
+ }
render() {
var content = '';