From 34542d9293fcc2d8199d7ac44a21eedcac3e4f8b Mon Sep 17 00:00:00 2001 From: Matthias Mandelartz <33543464+GHMatti@users.noreply.github.com> Date: Thu, 6 Sep 2018 09:11:08 +0200 Subject: [PATCH 1/2] Caching removed suggestions Fixes that if a suggestion is 'removed' before it is added due to conflicting resources, it will still show up. --- resources/[system]/chat/html/App.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/resources/[system]/chat/html/App.js b/resources/[system]/chat/html/App.js index c3ade18d6..42dc0620f 100644 --- a/resources/[system]/chat/html/App.js +++ b/resources/[system]/chat/html/App.js @@ -6,7 +6,8 @@ window.APP = { style: CONFIG.style, showInput: false, showWindow: false, - suggestions: [], + subtrahendSuggestions: [], + minuendSuggestions: [], templates: CONFIG.templates, message: '', messages: [], @@ -41,6 +42,11 @@ window.APP = { }); }, }, + computed: { + suggestions() { + return this.subtrahendSuggestions.filter((el) => this.minuendSuggestions.indexOf(el.name) <= -1); + }, + }, methods: { ON_OPEN() { this.showInput = true; @@ -68,13 +74,15 @@ window.APP = { if (!suggestion.params) { suggestion.params = []; //TODO Move somewhere else } - if (this.suggestions.find(a => a.name == suggestion.name)) { + if (this.subtrahendSuggestions.find(a => a.name == suggestion.name)) { return; } - this.suggestions.push(suggestion); + this.subtrahendSuggestions.push(suggestion); }, ON_SUGGESTION_REMOVE({ name }) { - this.suggestions = this.suggestions.filter((sug) => sug.name !== name) + if(this.minuendSuggestions.indexOf(name) <= -1) { + this.minuendSuggestions.push(name); + } }, ON_TEMPLATE_ADD({ template }) { if (this.templates[template.id]) { From 41e93abb980618435d86d9b2ffa80b81d3c50ded Mon Sep 17 00:00:00 2001 From: GHMatti <33543464+GHMatti@users.noreply.github.com> Date: Thu, 6 Sep 2018 11:02:07 +0200 Subject: [PATCH 2/2] Renamed variables to something better. --- resources/[system]/chat/html/App.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/resources/[system]/chat/html/App.js b/resources/[system]/chat/html/App.js index 42dc0620f..4b38eb471 100644 --- a/resources/[system]/chat/html/App.js +++ b/resources/[system]/chat/html/App.js @@ -6,8 +6,8 @@ window.APP = { style: CONFIG.style, showInput: false, showWindow: false, - subtrahendSuggestions: [], - minuendSuggestions: [], + backingSuggestions: [], + removedSuggestions: [], templates: CONFIG.templates, message: '', messages: [], @@ -44,7 +44,7 @@ window.APP = { }, computed: { suggestions() { - return this.subtrahendSuggestions.filter((el) => this.minuendSuggestions.indexOf(el.name) <= -1); + return this.backingSuggestions.filter((el) => this.removedSuggestions.indexOf(el.name) <= -1); }, }, methods: { @@ -74,14 +74,14 @@ window.APP = { if (!suggestion.params) { suggestion.params = []; //TODO Move somewhere else } - if (this.subtrahendSuggestions.find(a => a.name == suggestion.name)) { + if (this.backingSuggestions.find(a => a.name == suggestion.name)) { return; } - this.subtrahendSuggestions.push(suggestion); + this.backingSuggestions.push(suggestion); }, ON_SUGGESTION_REMOVE({ name }) { - if(this.minuendSuggestions.indexOf(name) <= -1) { - this.minuendSuggestions.push(name); + if(this.removedSuggestions.indexOf(name) <= -1) { + this.removedSuggestions.push(name); } }, ON_TEMPLATE_ADD({ template }) {