diff --git a/client/src/builtin/EmoteModule.js b/client/src/builtin/EmoteModule.js index 2a135ae2..07548c4e 100644 --- a/client/src/builtin/EmoteModule.js +++ b/client/src/builtin/EmoteModule.js @@ -37,6 +37,25 @@ export default new class EmoteModule extends BuiltinModule { get mostUsed() { return this._mostUsed || (this._mostUsed = []) } + get settingPath() { return ['emotes', 'default', 'enable'] } + + async enabled() { + GlobalAc.add(';', this); + + if (!this.database.size) { + await this.loadLocalDb(); + } + + this.patchMessageContent(); + MonkeyPatch('BD:EMOTEMODULE', WebpackModules.getModuleByName('MessageActions')).instead('sendMessage', this.handleSendMessage.bind(this)); + MonkeyPatch('BD:EMOTEMODULE', WebpackModules.getModuleByName('MessageActions')).instead('editMessage', this.handleEditMessage.bind(this)); + } + + async disabled() { + for (const patch of Patcher.getPatchesByCaller('BD:EMOTEMODULE')) patch.unpatch(); + GlobalAc.remove(';'); + } + addToMostUsed(emote) { const isMostUsed = this.mostUsed.find(mu => mu.key === emote.name); if (isMostUsed) { @@ -53,25 +72,6 @@ export default new class EmoteModule extends BuiltinModule { } } - get settingPath() { return ['emotes', 'default', 'enable'] } - - async enabled() { - - GlobalAc.add(';', this); - - if (!this.database.size) { - await this.loadLocalDb(); - } - - this.patchMessageContent(); - MonkeyPatch('BD:EMOTEMODULE', WebpackModules.getModuleByName('MessageActions')).instead('sendMessage', this.handleSendMessage.bind(this)); - MonkeyPatch('BD:EMOTEMODULE', WebpackModules.getModuleByName('MessageActions')).instead('editMessage', this.handleEditMessage.bind(this)); - } - - async disabled() { - for (const patch of Patcher.getPatchesByCaller('BD:EMOTEMODULE')) patch.unpatch(); - } - processMarkup(markup) { const newMarkup = []; if (!(markup instanceof Array)) return markup; diff --git a/client/src/ui/autocomplete.js b/client/src/ui/autocomplete.js index ddba54aa..3745c0f6 100644 --- a/client/src/ui/autocomplete.js +++ b/client/src/ui/autocomplete.js @@ -36,6 +36,10 @@ export default new class AutoComplete { this.sets[prefix] = controller; } + remove(prefix) { + if (this.sets.hasOwnProperty(prefix)) delete this.sets[prefix]; + } + validPrefix(prefix) { return this.sets.hasOwnProperty(prefix); }