chat: fix help text and params in chat suggestions

Fixed help text and params not being added after using `chat:addSuggestion` by allowing a chat suggestion to be "updated" new information.
This commit is contained in:
jaymo1011
2018-10-21 20:50:58 +10:30
committed by GitHub
parent 407b805616
commit 347de821c4

View File

@@ -77,12 +77,17 @@ window.APP = {
this.oldMessagesIndex = -1; this.oldMessagesIndex = -1;
}, },
ON_SUGGESTION_ADD({ suggestion }) { ON_SUGGESTION_ADD({ suggestion }) {
const duplicateSuggestion = this.backingSuggestions.find(a => a.name == suggestion.name);
if (duplicateSuggestion) {
if(suggestion.help || suggestion.params) {
duplicateSuggestion.help = suggestion.help || "";
duplicateSuggestion.params = suggestion.params || [];
}
return;
}
if (!suggestion.params) { if (!suggestion.params) {
suggestion.params = []; //TODO Move somewhere else suggestion.params = []; //TODO Move somewhere else
} }
if (this.backingSuggestions.find(a => a.name == suggestion.name)) {
return;
}
this.backingSuggestions.push(suggestion); this.backingSuggestions.push(suggestion);
}, },
ON_SUGGESTION_REMOVE({ name }) { ON_SUGGESTION_REMOVE({ name }) {