From ddccdcf22bb5008022e93c4789311fb2da95d7cf Mon Sep 17 00:00:00 2001 From: Noah Loomans Date: Sun, 10 Dec 2017 19:24:53 +0100 Subject: Refactor state names --- src/client/react/reducers/search.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/client/react/reducers/search.js') diff --git a/src/client/react/reducers/search.js b/src/client/react/reducers/search.js index 5d8fee5..52f3b4e 100644 --- a/src/client/react/reducers/search.js +++ b/src/client/react/reducers/search.js @@ -2,8 +2,8 @@ import fuzzy from 'fuzzy'; const DEFAULT_STATE = { - searchInput: '', - searchResults: [ + input: '', + results: [ { type: 's', value: '18561' }, ], exactMatch: null, @@ -31,6 +31,8 @@ const search = (state = DEFAULT_STATE, action) => { let results = getSearchResults(action.typedValue); let exactMatch = null; + // Is the typed value exactly the same as the first result? Then show the + // appropiate icon instead of the generic search icon. if ((results.length > 0) && (action.typedValue === results[0].value)) { [exactMatch] = results; results = results.splice(1); @@ -38,8 +40,8 @@ const search = (state = DEFAULT_STATE, action) => { return { ...state, - searchInput: action.typedValue, - searchResults: results, + input: action.typedValue, + results, exactMatch, }; } -- cgit v1.1