Skip to content
This repository has been archived by the owner on Apr 7, 2023. It is now read-only.

Commit

Permalink
Merge pull request #32 from GHMatti/master
Browse files Browse the repository at this point in the history
Caching removed suggestions
  • Loading branch information
blattersturm authored Sep 8, 2018
2 parents 22e3cc0 + 41e93ab commit 9914752
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions resources/[system]/chat/html/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ window.APP = {
style: CONFIG.style,
showInput: false,
showWindow: false,
suggestions: [],
backingSuggestions: [],
removedSuggestions: [],
templates: CONFIG.templates,
message: '',
messages: [],
Expand Down Expand Up @@ -41,6 +42,11 @@ window.APP = {
});
},
},
computed: {
suggestions() {
return this.backingSuggestions.filter((el) => this.removedSuggestions.indexOf(el.name) <= -1);
},
},
methods: {
ON_OPEN() {
this.showInput = true;
Expand Down Expand Up @@ -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.backingSuggestions.find(a => a.name == suggestion.name)) {
return;
}
this.suggestions.push(suggestion);
this.backingSuggestions.push(suggestion);
},
ON_SUGGESTION_REMOVE({ name }) {
this.suggestions = this.suggestions.filter((sug) => sug.name !== name)
if(this.removedSuggestions.indexOf(name) <= -1) {
this.removedSuggestions.push(name);
}
},
ON_TEMPLATE_ADD({ template }) {
if (this.templates[template.id]) {
Expand Down

0 comments on commit 9914752

Please sign in to comment.