From 78b88443c0eb301fc18663f6b42852575c1776a1 Mon Sep 17 00:00:00 2001 From: kyleplo <31634240+kyleplo@users.noreply.github.com> Date: Wed, 22 Aug 2018 14:17:26 -0400 Subject: [PATCH] Fix setting mode --- src/views/search/search.jsx | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/views/search/search.jsx b/src/views/search/search.jsx index fde867281..d9d87f659 100644 --- a/src/views/search/search.jsx +++ b/src/views/search/search.jsx @@ -37,6 +37,20 @@ class Search extends React.Component { this.state.mode = ''; this.state.offset = 0; this.state.loadMore = false; + + let mode = ''; + const m = query.lastIndexOf('mode='); + if (m !== -1) { + mode = query.substring(m + 5, query.length).toLowerCase(); + } + while (mode.indexOf('/') > -1) { + mode = mode.substring(0, term.indexOf('/')); + } + while (term.indexOf('&') > -1) { + mode = mode.substring(0, term.indexOf('&')); + } + mode = decodeURIComponent(mode.split('+').join(' ')); + this.state.mode = mode; } componentDidMount () { const query = window.location.search; @@ -53,20 +67,6 @@ class Search extends React.Component { } term = decodeURIComponent(term.split('+').join(' ')); this.props.dispatch(navigationActions.setSearchTerm(term)); - - let mode = ''; - const m = query.lastIndexOf('mode='); - if (m !== -1) { - mode = query.substring(m + 5, query.length).toLowerCase(); - } - while (mode.indexOf('/') > -1) { - mode = mode.substring(0, term.indexOf('/')); - } - while (term.indexOf('&') > -1) { - mode = mode.substring(0, term.indexOf('&')); - } - mode = decodeURIComponent(mode.split('+').join(' ')); - this.setState({mode: mode}); } componentDidUpdate (prevProps) { if (this.props.searchTerm !== prevProps.searchTerm) {