Add setting to enable/disable emotes
This commit is contained in:
parent
e83c6f92cb
commit
1bde3b4ec9
|
@ -24,6 +24,18 @@ export default new class EmoteModule {
|
|||
this.favourite_emotes = [];
|
||||
}
|
||||
|
||||
init() {
|
||||
this.enabledSetting = Settings.getSetting('emotes', 'default', 'enable');
|
||||
this.enabledSetting.on('setting-updated', event => {
|
||||
// Rerender all messages (or if we're disabling emotes, those that have emotes)
|
||||
for (const message of document.querySelectorAll(event.value ? '.message' : '.bd-emote-outer')) {
|
||||
Reflection(event.value ? message : message.closest('.message')).forceUpdate();
|
||||
}
|
||||
});
|
||||
|
||||
return this.observe();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets an emote as favourite.
|
||||
* @param {String} emote The name of the emote
|
||||
|
@ -66,7 +78,7 @@ export default new class EmoteModule {
|
|||
}
|
||||
|
||||
processMarkup(markup, timestamp) {
|
||||
if (!emotesEnabled) return markup; // TODO Get it from setttings
|
||||
if (!this.enabledSetting.value) return markup;
|
||||
|
||||
timestamp = timestamp.valueOf();
|
||||
const allowNoWrapper = timestamp < enforceWrapperFrom;
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
"headertext": "Core Settings",
|
||||
"settings": [
|
||||
{
|
||||
"category": "default",
|
||||
"id": "default",
|
||||
"settings": [
|
||||
{
|
||||
"id": "test-setting",
|
||||
|
@ -40,8 +40,8 @@
|
|||
]
|
||||
},
|
||||
{
|
||||
"category": "advanced",
|
||||
"category_name": "Advanced",
|
||||
"id": "advanced",
|
||||
"name": "Advanced",
|
||||
"type": "drawer",
|
||||
"settings": [
|
||||
{
|
||||
|
@ -74,7 +74,7 @@
|
|||
"headertext": "UI Settings",
|
||||
"settings": [
|
||||
{
|
||||
"category": "default",
|
||||
"id": "default",
|
||||
"settings": [
|
||||
{
|
||||
"id": "hide-button",
|
||||
|
@ -92,14 +92,26 @@
|
|||
"id": "emotes",
|
||||
"text": "Emotes",
|
||||
"headertext": "Emote Settings",
|
||||
"settings": []
|
||||
"settings": [
|
||||
{
|
||||
"id": "default",
|
||||
"settings": [
|
||||
{
|
||||
"id": "enable",
|
||||
"type": "bool",
|
||||
"text": "Enable emotes",
|
||||
"value": true
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "css",
|
||||
"text": "CSS Editor",
|
||||
"settings": [
|
||||
{
|
||||
"category": "default",
|
||||
"id": "default",
|
||||
"settings": [
|
||||
{
|
||||
"id": "live-update",
|
||||
|
@ -123,8 +135,6 @@
|
|||
"id": "security",
|
||||
"text": "Security",
|
||||
"headertext": "Security Settings",
|
||||
"settings": [
|
||||
|
||||
]
|
||||
"settings": []
|
||||
}
|
||||
]
|
||||
|
|
|
@ -76,7 +76,7 @@ class BetterDiscord {
|
|||
|
||||
Events.emit('ready');
|
||||
Events.emit('discord-ready');
|
||||
EmoteModule.observe();
|
||||
EmoteModule.init();
|
||||
} catch (err) {
|
||||
Logger.err('main', ['FAILED TO LOAD!', err]);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue