diff options
author | Noah Loomans <noahloomans@gmail.com> | 2018-02-04 11:36:44 +0100 |
---|---|---|
committer | Noah Loomans <noahloomans@gmail.com> | 2018-02-04 11:36:44 +0100 |
commit | c325916e381d6ac13fcc840b2d4baa87913a3184 (patch) | |
tree | 398b7c274f6d41db28d331d5925d12acf8701ca6 /src/client/react/reducers/search.js | |
parent | 77f5b8fbe87ce992c46ee5513eaa25c7a7f129ec (diff) |
Reimplement isExactMatch to compair against the url user.
Diffstat (limited to 'src/client/react/reducers/search.js')
-rw-r--r-- | src/client/react/reducers/search.js | 28 |
1 files changed, 5 insertions, 23 deletions
diff --git a/src/client/react/reducers/search.js b/src/client/react/reducers/search.js index 770cdcb..6293b8a 100644 --- a/src/client/react/reducers/search.js +++ b/src/client/react/reducers/search.js @@ -8,7 +8,6 @@ const DEFAULT_STATE = { results: [], searchText: '', selectedResult: null, - isExactMatch: false, }; function getSearchResults(allUsers, query) { @@ -40,36 +39,19 @@ const search = (state = DEFAULT_STATE, action) => { results: [], searchText: users.byId[user].value, selectedResult: user, - isExactMatch: true, }; } - case 'SEARCH/INPUT_CHANGE': { - const { searchText } = action; - const results = getSearchResults(users.allUsers, action.searchText); - let selectedResult = null; - let isExactMatch = false; - - // Is the typed value exactly the same as the first result? Then show the - // appropriate icon instead of the generic search icon. - if ((results.length === 1) && (action.searchText === users.byId[results[0]].value)) { - [selectedResult] = results; - isExactMatch = true; - } - + case 'SEARCH/INPUT_CHANGE': return { ...state, - results, - searchText, - selectedResult, - isExactMatch, + results: getSearchResults(users.allUsers, action.searchText), + searchText: action.searchText, + selectedResult: null, }; - } case 'SEARCH/CHANGE_SELECTED_RESULT': { - const { results, isExactMatch } = state; - - if (isExactMatch) return state; + const { results } = state; const prevSelectedResult = state.selectedResult; const prevSelectedResultIndex = results.indexOf(prevSelectedResult); |