From 347de821c4e6b84c71bfd6ff4edf8ade157d45e7 Mon Sep 17 00:00:00 2001 From: jaymo1011 Date: Sun, 21 Oct 2018 20:50:58 +1030 Subject: [PATCH] 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. --- resources/[system]/chat/html/App.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/resources/[system]/chat/html/App.js b/resources/[system]/chat/html/App.js index 77769e1..6e54d2f 100644 --- a/resources/[system]/chat/html/App.js +++ b/resources/[system]/chat/html/App.js @@ -77,12 +77,17 @@ window.APP = { this.oldMessagesIndex = -1; }, 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) { suggestion.params = []; //TODO Move somewhere else } - if (this.backingSuggestions.find(a => a.name == suggestion.name)) { - return; - } this.backingSuggestions.push(suggestion); }, ON_SUGGESTION_REMOVE({ name }) {