From c91822cdc98af666eb70be3503212d83070bfa89 Mon Sep 17 00:00:00 2001 From: SirStendec Date: Tue, 31 Dec 2019 19:32:55 -0500 Subject: [PATCH] 4.17.12 * Added: Better support for settings profiles on the dashboard. * Fixed: Bug with the new title-based filtering for settings profiles frequently toggling on and off. * Fixed: Bug with settings context inheritance. --- package.json | 2 +- src/settings/context.js | 2 +- src/settings/filters.js | 5 +- .../twitch-twilight/modules/dashboard.js | 69 ++++++++++++++++--- 4 files changed, 66 insertions(+), 12 deletions(-) diff --git a/package.json b/package.json index 4a74cccc..e3582ada 100755 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "frankerfacez", "author": "Dan Salvato LLC", - "version": "4.17.11", + "version": "4.17.12", "description": "FrankerFaceZ is a Twitch enhancement suite.", "license": "Apache-2.0", "scripts": { diff --git a/src/settings/context.js b/src/settings/context.js index 3117ba07..cff67d2d 100644 --- a/src/settings/context.js +++ b/src/settings/context.js @@ -104,7 +104,7 @@ export default class SettingsContext extends EventEmitter { _rebuildContext() { this.__context = this.parent ? - Object.assign({}, this.parent._context, this._context) : + Object.assign({}, this.parent.__context || this.parent._context, this._context) : this._context; // Make sure we re-build the cache. Dependency hell. diff --git a/src/settings/filters.js b/src/settings/filters.js index 5f95af4a..fe3ed2db 100644 --- a/src/settings/filters.js +++ b/src/settings/filters.js @@ -313,7 +313,10 @@ export const Title = { return () => false; } - return ctx => ctx.title && regex.test(ctx.title) + return ctx => { + regex.lastIndex = 0; + return ctx.title && regex.test(ctx.title); + } }, title: 'Current Title', diff --git a/src/sites/twitch-twilight/modules/dashboard.js b/src/sites/twitch-twilight/modules/dashboard.js index 57103d3a..5fc76814 100644 --- a/src/sites/twitch-twilight/modules/dashboard.js +++ b/src/sites/twitch-twilight/modules/dashboard.js @@ -7,6 +7,8 @@ import Module from 'utilities/module'; import { get } from 'utilities/object'; +import Twilight from 'site'; + export default class Dashboard extends Module { constructor(...args) { super(...args); @@ -15,36 +17,85 @@ export default class Dashboard extends Module { this.inject('settings'); this.inject('site.fine'); + this.inject('site.channel'); + + this.HostBar = this.fine.define( + 'sunlight-host-bar', + n => n.props && n.props.channel && n.props.hostedChannel !== undefined, + Twilight.SUNLIGHT_ROUTES + ) this.Dashboard = this.fine.define( - 'dashboard', - n => n.cards && n.defaultCards && n.saveCardsConfig, - ['dash'] + 'sunlight-dash', + n => n.getIsChannelEditor && n.getIsChannelModerator && n.getIsAdsEnabled && n.getIsSquadStreamsEnabled, + Twilight.SUNLIGHT_ROUTES ); } onEnable() { - this.Dashboard.on('mount', this.onUpdate, this); - this.Dashboard.on('update', this.onUpdate, this); - this.Dashboard.on('unmount', this.onUnmount, this); + this.Dashboard.on('mount', this.onDashUpdate, this); + this.Dashboard.on('update', this.onDashUpdate, this); + this.Dashboard.on('unmount', this.onDashUnmount, this); + + this.HostBar.on('mount', this.onHostBarUpdate, this); + this.HostBar.on('update', this.onHostBarUpdate, this); + this.HostBar.on('unmount', this.onHostBarUnmount, this); this.Dashboard.ready((cls, instances) => { for(const inst of instances) - this.onUpdate(inst); + this.onDashUpdate(inst); + }); + + this.HostBar.ready((cls, instances) => { + for(const inst of instances) + this.onHostBarUpdate(inst); }); } - onUpdate(inst) { + onDashUpdate(inst) { this.settings.updateContext({ channel: get('props.channelLogin', inst), channelID: get('props.channelID', inst) }); } - onUnmount() { + onDashUnmount() { this.settings.updateContext({ channel: null, channelID: null }); } + + onHostBarUpdate(inst) { + const channel = inst.props?.channel, + source = channel?.stream || channel?.broadcastSettings; + + const game = source?.game, + title = source?.title || null, + color = channel?.primaryColorHex || null; + + this.channel.updateChannelColor(color); + + this.settings.updateContext({ + /*channel: channel?.login, + channelID: channel?.id,*/ + category: game?.name, + categoryID: game?.id, + title, + channelColor: color, + hosting: !! inst.props?.hostedChannel + }); + } + + onHostBarUnmount() { + this.settings.updateContext({ + /*channel: null, + channelID: null,*/ + channelColor: null, + category: null, + categoryID: null, + title: null, + hosting: false + }); + } } \ No newline at end of file