aboutsummaryrefslogtreecommitdiff
path: root/src/client/react/reducers
diff options
context:
space:
mode:
authorNoah Loomans <noahloomans@gmail.com>2017-12-10 15:58:25 +0100
committerNoah Loomans <noahloomans@gmail.com>2017-12-10 15:58:25 +0100
commit797fb96cd0001d6c739c89507befc73d3d8a6614 (patch)
treeb5471fb96399526d056b5a57553313a92f22ed12 /src/client/react/reducers
parent36dc0fb88258af24069f61935656334c35ef13b3 (diff)
Show user icon instead of search icon on exact match
Diffstat (limited to 'src/client/react/reducers')
-rw-r--r--src/client/react/reducers/search.js15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/client/react/reducers/search.js b/src/client/react/reducers/search.js
index 72fa469..dd737ed 100644
--- a/src/client/react/reducers/search.js
+++ b/src/client/react/reducers/search.js
@@ -6,6 +6,7 @@ const DEFAULT_STATE = {
searchResults: [
{ type: 's', value: '18561' },
],
+ exactMatch: null,
hasFocus: false,
};
@@ -26,12 +27,22 @@ function getSearchResults(query) {
const search = (state = DEFAULT_STATE, action) => {
switch (action.type) {
- case 'SEARCH/INPUT_CHANGE':
+ case 'SEARCH/INPUT_CHANGE': {
+ let results = getSearchResults(action.typedValue);
+ let exactMatch = false;
+
+ if ((results.length > 0) && (action.typedValue === results[0].value)) {
+ [exactMatch] = results;
+ results = results.splice(1);
+ }
+
return {
...state,
searchInput: action.typedValue,
- searchResults: getSearchResults(action.typedValue),
+ searchResults: results,
+ exactMatch,
};
+ }
case 'SEARCH/FOCUS_CHANGE':
return {
...state,