From e750020d3b660325fc31c1b8cfa9808a94e895af Mon Sep 17 00:00:00 2001 From: Ftwpala Date: Sat, 11 Nov 2023 00:41:51 +0100 Subject: [PATCH] Swarm emote combo fix (#511) * Fix for swarm combos while emotes are disabled + swapped season to "december" because of christmas emotes * renamed IdentityFormatter to DisabledFormatter --- assets/chat/js/const.js | 2 +- assets/chat/js/formatters.js | 4 ++-- assets/chat/js/messages.js | 16 +++++++++------- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/assets/chat/js/const.js b/assets/chat/js/const.js index 901de16b..d2cb1573 100644 --- a/assets/chat/js/const.js +++ b/assets/chat/js/const.js @@ -164,7 +164,7 @@ const TAGS = [ "weeb", ]; -const SEASON = "june"; +const SEASON = "december"; module.exports = { KEYCODES, diff --git a/assets/chat/js/formatters.js b/assets/chat/js/formatters.js index 39071ba4..8faa5a1d 100644 --- a/assets/chat/js/formatters.js +++ b/assets/chat/js/formatters.js @@ -217,7 +217,7 @@ function moveModifierToFront(modifierList, modifierName) { return modifierList; } -class IdentityFormatter { +class DisabledFormatter { format(chat, str, message = null) { return str; } @@ -750,7 +750,7 @@ export { EmoteFormatter, GreenTextFormatter, HtmlTextFormatter, - IdentityFormatter, + DisabledFormatter as IdentityFormatter, MentionedUserFormatter, RawEmoteFormatter, SpoilerFormatter, diff --git a/assets/chat/js/messages.js b/assets/chat/js/messages.js index ee018008..95e815e9 100644 --- a/assets/chat/js/messages.js +++ b/assets/chat/js/messages.js @@ -6,7 +6,7 @@ import { HtmlTextFormatter, MentionedUserFormatter, UrlFormatter, - IdentityFormatter, + DisabledFormatter, CodeFormatter, SpoilerFormatter } from "./formatters"; @@ -36,9 +36,9 @@ formatters.set("green", new GreenTextFormatter()); function setFormattersFromSettings(settings) { if (!settings.get("formatter-emote")) - formatters.set("emote", new IdentityFormatter()); + formatters.set("emote", new DisabledFormatter()); if (!settings.get("formatter-green")) - formatters.set("green", new IdentityFormatter()); + formatters.set("green", new DisabledFormatter()); } function buildMessageTxt(chat, message) { @@ -440,9 +440,11 @@ function ChatEmoteMessageCount(message) { if (!message._combo) console.error("no combo", message._combo); message._combo.attr("class", "chat-combo" + stepClass); + // TODO: currently this does not get hit on "2x" combos, and requires a hack to get swarm emotes to work properly. + // consider finding the reason why it isn't going into this function on "2x" combos and swarm emote hack in the "afterRender" function in the ChatEmoteMessage class if ( SWARM_EMOTES.includes(message.message.split(":")[0]) && - message.emotecount <= 6 + message.emotecount <= 6 && !(formatters.get("emote") instanceof DisabledFormatter) ) { message._text.attr("class", message.message.split(":")[0] + "Combo"); @@ -452,7 +454,7 @@ function ChatEmoteMessageCount(message) { " "; let html = ""; - // for every combo attatch 1 emote + // for every combo attach 1 emote for (let i = 0; i < message.emotecount; i++) { html += temp; } @@ -494,8 +496,8 @@ class ChatEmoteMessage extends ChatMessage { " ", this._combo_txt ); - - if (SWARM_EMOTES.includes(this.message.split(":")[0])) { + // this fixes a bug when an emote hits "2x" it does not enter the ChatEmoteMessageCount function until 3x + if (SWARM_EMOTES.includes(this.message.split(":")[0]) && !(formatters.get("emote") instanceof DisabledFormatter)) { this._text.attr("class", this.message.split(":")[0] + "Combo"); this._text.append( `${formatters.get("emote").format(chat, this.message, this)}`