From 3c37dbf23aed6b12f56bd4a73afcc8d0918d1dd2 Mon Sep 17 00:00:00 2001 From: SirStendec Date: Sat, 1 May 2021 14:36:20 -0400 Subject: [PATCH] 4.22.1 * Fixed: Unread whispers not appearing correctly when the color normalizer is loaded. * Fixed: Performance issue creating excessive `FFZEvent` instances in `flushRawBuffer` when no message was scheduled for display. * API Fixed: The `chat:buffer-message` event not including `channelID` and `channel` properties. --- package.json | 2 +- .../twitch-twilight/modules/chat/index.js | 53 ++++++++++++++++--- .../styles/color_normalizer.scss | 13 ++++- 3 files changed, 57 insertions(+), 11 deletions(-) diff --git a/package.json b/package.json index 2c77105a..09bfd677 100755 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "frankerfacez", "author": "Dan Salvato LLC", - "version": "4.22.0", + "version": "4.22.1", "description": "FrankerFaceZ is a Twitch enhancement suite.", "private": true, "license": "Apache-2.0", diff --git a/src/sites/twitch-twilight/modules/chat/index.js b/src/sites/twitch-twilight/modules/chat/index.js index dc13f2c9..eb4c4d54 100644 --- a/src/sites/twitch-twilight/modules/chat/index.js +++ b/src/sites/twitch-twilight/modules/chat/index.js @@ -1481,10 +1481,10 @@ export default class ChatHook extends Module { if ( msg.type === types.Message ) { const m = t.chat.standardizeMessage(msg), - cont = inst._ffz_connector, - room_id = cont && cont.props.channelID; + cont = inst._ffz_connector ?? inst.ffzGetConnector(); - let room = m.roomLogin = m.roomLogin ? m.roomLogin : m.channel ? m.channel.slice(1) : cont && cont.props.channelLogin; + let room_id = m.roomID = m.roomID ? m.roomID : cont?.props?.channelID; + let room = m.roomLogin = m.roomLogin ? m.roomLogin : m.channel ? m.channel.slice(1) : cont?.props?.channelLogin; if ( ! room && room_id ) { const r = t.chat.getRoom(room_id, null, true); @@ -1492,6 +1492,12 @@ export default class ChatHook extends Module { room = m.roomLogin = r.login; } + if ( ! room_id && room ) { + const r = t.chat.getRoom(null, room, true); + if ( r && r.id ) + room_id = m.roomID = r.id; + } + const u = t.site.getUser(); if ( u && cont ) { u.moderator = cont.props.isCurrentUserModerator; @@ -1505,6 +1511,7 @@ export default class ChatHook extends Module { if ( t.hasListeners('chat:receive-message') ) { const event = new FFZEvent({ message: m, + inst, channel: room, channelID: room_id }); @@ -1781,6 +1788,19 @@ export default class ChatHook extends Module { } } + cls.prototype.ffzGetConnector = function() { + if ( this._ffz_connector ) + return this._ffz_connector; + + const now = Date.now(); + if ( now - (this._ffz_connect_tried || 0) > 5000 ) { + this._ffz_connect_tried = now; + const thing = t.ChatBufferConnector.first; + if ( thing?.props?.messageBufferAPI?._ffz_inst === this ) + return this._ffz_connector = thing; + } + } + cls.prototype.flushRawMessages = function() { try { const out = [], @@ -1795,21 +1815,38 @@ export default class ChatHook extends Module { max_size = t.chat.context.get('chat.scrollback-length'), do_remove = t.chat.context.get('chat.filtering.remove-deleted'), - event = t.hasListeners('chat:buffer-message') ? new FFZEvent() : null; + want_event = t.hasListeners('chat:buffer-message'); let added = 0, buffered = this.slidingWindowEnd, - changed = false; + changed = false, + event; for(const msg of this.delayedMessageBuffer) { if ( msg.time <= first || ! msg.shouldDelay ) { if ( do_remove !== 0 && (do_remove > 1 || ! see_deleted) && this.isDeletable(msg.event) && msg.event.deleted ) continue; - if ( event ) { - event._reset(); - event.message = msg.event; + if ( want_event ) { + if ( ! event ) { + event = new FFZEvent(); + const cont = this._ffz_connector ?? this.ffzGetConnector(), + room_id = cont && cont.props.channelID; + + event.inst = this; + event.channelID = room_id; + + if ( room_id ) { + const r = t.chat.getRoom(room_id, null, true); + if ( r && r.login ) + event.channel = r.login; + } + + } else + event._reset(); + + event.message = msg.event; t.emit('chat:buffer-message', event); if ( event.defaultPrevented || msg.event.ffz_removed ) continue; diff --git a/src/sites/twitch-twilight/styles/color_normalizer.scss b/src/sites/twitch-twilight/styles/color_normalizer.scss index faeb02ca..ee5c1274 100644 --- a/src/sites/twitch-twilight/styles/color_normalizer.scss +++ b/src/sites/twitch-twilight/styles/color_normalizer.scss @@ -27,18 +27,27 @@ .top-stats-tab:hover, .whispers-list-item--selected, .side-nav__overlay-wrapper, - .thread-header__title-bar-container--focused { + .thread-header__title-bar-container { background-color: var(--color-background-alt) !important; } .whispers-list-item:hover .whispers-list-item__archive-button:hover, .clmgr-table__row:hover, - .thread-header__title-bar-container, + .thread-header__title-bar-container.thread-header__title-bar-container--focused, .whispers-list-item:hover, .side-nav-card__link:hover { background-color: var(--color-background-alt-2) !important; } + .thread-header__title-bar-container--highlighted, + .thread-header__title-bar-container--highlighted { + background-color: var(--color-background-button) !important; + + &:hover { + background-color: var(--color-background-button-hover) !important; + } + } + .top-stats-tab, .channel-header__user { color: var(--color-text-base) !important;