From c4f28a6ac55c9e550e3bf6c3c7eefb821ff3fb7f Mon Sep 17 00:00:00 2001 From: Jiiks Date: Wed, 22 Aug 2018 17:17:37 +0300 Subject: [PATCH] Initial favouriting and horrible toggle code fix it Zere --- client/src/builtin/EmoteModule.js | 14 ++++++++++++-- client/src/ui/components/contextmenu/Group.vue | 4 ++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/client/src/builtin/EmoteModule.js b/client/src/builtin/EmoteModule.js index 71a4031b..e713e187 100644 --- a/client/src/builtin/EmoteModule.js +++ b/client/src/builtin/EmoteModule.js @@ -60,8 +60,18 @@ export default new class EmoteModule extends BuiltinModule { { text: 'Favourite', type: 'toggle', - checked: (target) => { console.log(target); if (target.alt && target.alt === ';cirThree;') { console.log('yes'); return true; } else return false; }, - onChange: (checked, target) => { if (target.alt && target.alt === ';cirThree;') { console.log('yes'); return true; } else return false; } + checked: (target) => { + const { alt } = target; + if (!alt) return false; + return this.favourites.find(e => e.alt === alt); + }, + onChange: (checked, target) => { + const { alt } = target; + if (!alt) return false; + const fav = this.favourites.find(e => e.alt === alt); + if (fav) return this._favourites = this._favourites.filter(e => e.alt !== target.alt); + this.favourites.push({ alt: target.alt }); + } } ], filter => filter.closest('.bd-emote')); diff --git a/client/src/ui/components/contextmenu/Group.vue b/client/src/ui/components/contextmenu/Group.vue index df2a4cef..2b5ac048 100644 --- a/client/src/ui/components/contextmenu/Group.vue +++ b/client/src/ui/components/contextmenu/Group.vue @@ -12,14 +12,14 @@