summaryrefslogtreecommitdiffstats
path: root/webapp/stores/suggestion_store.jsx
diff options
context:
space:
mode:
authorJoram Wilander <jwawilander@gmail.com>2016-12-12 19:52:19 -0500
committerenahum <nahumhbl@gmail.com>2016-12-12 21:52:19 -0300
commit27aaa6dad37d77bc8a2660b27980c4ebd5957250 (patch)
treecdf506c03bb25f44bac5abe136919b156782f317 /webapp/stores/suggestion_store.jsx
parente28dea6b115fe5138591aee89804ed91da1a035a (diff)
downloadchat-27aaa6dad37d77bc8a2660b27980c4ebd5957250.tar.gz
chat-27aaa6dad37d77bc8a2660b27980c4ebd5957250.tar.bz2
chat-27aaa6dad37d77bc8a2660b27980c4ebd5957250.zip
Fix JS errors with RHS and flagged posts (#4771)
Diffstat (limited to 'webapp/stores/suggestion_store.jsx')
-rw-r--r--webapp/stores/suggestion_store.jsx28
1 files changed, 14 insertions, 14 deletions
diff --git a/webapp/stores/suggestion_store.jsx b/webapp/stores/suggestion_store.jsx
index 83c0c2a17..2dbef0490 100644
--- a/webapp/stores/suggestion_store.jsx
+++ b/webapp/stores/suggestion_store.jsx
@@ -87,7 +87,7 @@ class SuggestionStore extends EventEmitter {
}
clearSuggestions(id) {
- const suggestion = this.suggestions.get(id);
+ const suggestion = this.getSuggestions(id);
suggestion.matchedPretext = [];
suggestion.terms = [];
@@ -96,23 +96,23 @@ class SuggestionStore extends EventEmitter {
}
clearSelection(id) {
- const suggestion = this.suggestions.get(id);
+ const suggestion = this.getSuggestions(id);
suggestion.selection = '';
}
hasSuggestions(id) {
- return this.suggestions.get(id).terms.length > 0;
+ return this.getSuggestions(id).terms.length > 0;
}
setPretext(id, pretext) {
- const suggestion = this.suggestions.get(id);
+ const suggestion = this.getSuggestions(id);
suggestion.pretext = pretext;
}
addSuggestion(id, term, item, component, matchedPretext) {
- const suggestion = this.suggestions.get(id);
+ const suggestion = this.getSuggestions(id);
suggestion.terms.push(term);
suggestion.items.push(item);
@@ -126,7 +126,7 @@ class SuggestionStore extends EventEmitter {
return;
}
- const suggestion = this.suggestions.get(id);
+ const suggestion = this.getSuggestions(id);
suggestion.terms.push(...terms);
suggestion.items.push(...items);
@@ -139,7 +139,7 @@ class SuggestionStore extends EventEmitter {
// make sure that if suggestions exist, then one of them is selected. return true if the selection changes.
ensureSelectionExists(id) {
- const suggestion = this.suggestions.get(id);
+ const suggestion = this.getSuggestions(id);
if (suggestion.terms.length > 0) {
// if the current selection is no longer in the map, select the first term in the list
@@ -158,11 +158,11 @@ class SuggestionStore extends EventEmitter {
}
getPretext(id) {
- return this.suggestions.get(id).pretext;
+ return this.getSuggestions(id).pretext;
}
getSelectedMatchedPretext(id) {
- const suggestion = this.suggestions.get(id);
+ const suggestion = this.getSuggestions(id);
for (let i = 0; i < suggestion.terms.length; i++) {
if (suggestion.terms[i] === suggestion.selection) {
@@ -174,23 +174,23 @@ class SuggestionStore extends EventEmitter {
}
getItems(id) {
- return this.suggestions.get(id).items;
+ return this.getSuggestions(id).items;
}
getTerms(id) {
- return this.suggestions.get(id).terms;
+ return this.getSuggestions(id).terms;
}
getComponents(id) {
- return this.suggestions.get(id).components;
+ return this.getSuggestions(id).components;
}
getSuggestions(id) {
- return this.suggestions.get(id);
+ return this.suggestions.get(id) || {};
}
getSelection(id) {
- return this.suggestions.get(id).selection;
+ return this.getSuggestions(id).selection;
}
selectNext(id) {