summaryrefslogtreecommitdiffstats
path: root/webapp/stores/suggestion_store.jsx
diff options
context:
space:
mode:
authorHarrison Healey <harrisonmhealey@gmail.com>2016-11-10 17:00:14 -0500
committerGitHub <noreply@github.com>2016-11-10 17:00:14 -0500
commit03e3ac60c20bfc93752f9e57cdd5dec1cf397fa5 (patch)
treecff36ef60da9596059f3a94b7a7d5cdd09665727 /webapp/stores/suggestion_store.jsx
parent2fdb33042a118831de60d96e7138209e973e0d65 (diff)
downloadchat-03e3ac60c20bfc93752f9e57cdd5dec1cf397fa5.tar.gz
chat-03e3ac60c20bfc93752f9e57cdd5dec1cf397fa5.tar.bz2
chat-03e3ac60c20bfc93752f9e57cdd5dec1cf397fa5.zip
PLT-4600 Properly clear autocomplete suggestions when suggestions are out of date (#4529)
* PLT-4600 Better clear autocomplete suggestions when suggestions are out of date * Fixed react warnings and removed an eslint ignore
Diffstat (limited to 'webapp/stores/suggestion_store.jsx')
-rw-r--r--webapp/stores/suggestion_store.jsx8
1 files changed, 7 insertions, 1 deletions
diff --git a/webapp/stores/suggestion_store.jsx b/webapp/stores/suggestion_store.jsx
index 75221421f..d87b07076 100644
--- a/webapp/stores/suggestion_store.jsx
+++ b/webapp/stores/suggestion_store.jsx
@@ -121,6 +121,11 @@ class SuggestionStore extends EventEmitter {
}
addSuggestions(id, terms, items, component, matchedPretext) {
+ if (this.getPretext(id) !== matchedPretext) {
+ // These suggestions are out of date since the pretext has changed
+ return;
+ }
+
const suggestion = this.suggestions.get(id);
suggestion.terms.push(...terms);
@@ -218,7 +223,7 @@ class SuggestionStore extends EventEmitter {
}
handleEventPayload(payload) {
- const {type, id, ...other} = payload.action; // eslint-disable-line no-use-before-define
+ const {type, id, ...other} = payload.action;
switch (type) {
case ActionTypes.SUGGESTION_PRETEXT_CHANGED:
@@ -243,6 +248,7 @@ class SuggestionStore extends EventEmitter {
this.emitSuggestionsChanged(id);
break;
case ActionTypes.SUGGESTION_CLEAR_SUGGESTIONS:
+ this.setPretext(id, '');
this.clearSuggestions(id);
this.clearSelection(id);
this.emitSuggestionsChanged(id);