1
0
Fork 0
mirror of https://github.com/FrankerFaceZ/FrankerFaceZ.git synced 2025-08-11 08:30:55 +00:00
* 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.
This commit is contained in:
SirStendec 2019-12-31 19:32:55 -05:00
parent 4e0ed7ddcb
commit c91822cdc9
4 changed files with 66 additions and 12 deletions

View file

@ -1,7 +1,7 @@
{ {
"name": "frankerfacez", "name": "frankerfacez",
"author": "Dan Salvato LLC", "author": "Dan Salvato LLC",
"version": "4.17.11", "version": "4.17.12",
"description": "FrankerFaceZ is a Twitch enhancement suite.", "description": "FrankerFaceZ is a Twitch enhancement suite.",
"license": "Apache-2.0", "license": "Apache-2.0",
"scripts": { "scripts": {

View file

@ -104,7 +104,7 @@ export default class SettingsContext extends EventEmitter {
_rebuildContext() { _rebuildContext() {
this.__context = this.parent ? this.__context = this.parent ?
Object.assign({}, this.parent._context, this._context) : Object.assign({}, this.parent.__context || this.parent._context, this._context) :
this._context; this._context;
// Make sure we re-build the cache. Dependency hell. // Make sure we re-build the cache. Dependency hell.

View file

@ -313,7 +313,10 @@ export const Title = {
return () => false; 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', title: 'Current Title',

View file

@ -7,6 +7,8 @@
import Module from 'utilities/module'; import Module from 'utilities/module';
import { get } from 'utilities/object'; import { get } from 'utilities/object';
import Twilight from 'site';
export default class Dashboard extends Module { export default class Dashboard extends Module {
constructor(...args) { constructor(...args) {
super(...args); super(...args);
@ -15,36 +17,85 @@ export default class Dashboard extends Module {
this.inject('settings'); this.inject('settings');
this.inject('site.fine'); 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( this.Dashboard = this.fine.define(
'dashboard', 'sunlight-dash',
n => n.cards && n.defaultCards && n.saveCardsConfig, n => n.getIsChannelEditor && n.getIsChannelModerator && n.getIsAdsEnabled && n.getIsSquadStreamsEnabled,
['dash'] Twilight.SUNLIGHT_ROUTES
); );
} }
onEnable() { onEnable() {
this.Dashboard.on('mount', this.onUpdate, this); this.Dashboard.on('mount', this.onDashUpdate, this);
this.Dashboard.on('update', this.onUpdate, this); this.Dashboard.on('update', this.onDashUpdate, this);
this.Dashboard.on('unmount', this.onUnmount, 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) => { this.Dashboard.ready((cls, instances) => {
for(const inst of 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({ this.settings.updateContext({
channel: get('props.channelLogin', inst), channel: get('props.channelLogin', inst),
channelID: get('props.channelID', inst) channelID: get('props.channelID', inst)
}); });
} }
onUnmount() { onDashUnmount() {
this.settings.updateContext({ this.settings.updateContext({
channel: null, channel: null,
channelID: 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
});
}
} }