1
0
Fork 0
mirror of https://github.com/FrankerFaceZ/FrankerFaceZ.git synced 2025-10-11 13:41:57 +00:00
* Changed: Update the styling for rich chat embeds to match modern vanilla Twitch.
* Fixed: Do not display FFZ's Alternative Viewer Count if the stream is not live.
* Fixed: Automatically opening the chat when accessing a channel. (Now using route state instead of page elements.)
* Fixed: Dual channel points redemption messages when FFZ is rendering them.
* Fixed: Stopping the host video player when accessing a user's home page.
* Removed: The old, unfinished logviewer module. Logviewer is a dead project.

* API Changed: Add support for rich formatting in rich chat embeds.
* API Changed: `fine-router` can now check state when determining the current route.
This commit is contained in:
SirStendec 2020-07-26 17:50:14 -04:00
parent fa3d73e05a
commit a4fa1d1491
21 changed files with 451 additions and 629 deletions

View file

@ -6,7 +6,7 @@
import {parse, tokensToRegExp, tokensToFunction} from 'path-to-regexp';
import Module from 'utilities/module';
import {has} from 'utilities/object';
import {has, deep_equals} from 'utilities/object';
export default class FineRouter extends Module {
@ -39,20 +39,27 @@ export default class FineRouter extends Module {
this._navigateTo(history.location);
}
navigate(route, data, opts) {
this.history.push(this.getURL(route, data, opts));
navigate(route, data, opts, state) {
this.history.push(this.getURL(route, data, opts), state);
}
_navigateTo(location) {
this.log.debug('New Location', location);
const host = window.location.host,
path = location.pathname;
path = location.pathname,
state = location.state;
if ( path === this.location && host === this.domain )
if ( path === this.location && host === this.domain && deep_equals(state, this.current_state) )
return;
this.old_location = this.location;
this.old_domain = this.domain;
this.old_state = this.current_state;
this.location = path;
this.domain = host;
this.current_state = state;
this._pickRoute();
}
@ -60,12 +67,16 @@ export default class FineRouter extends Module {
const path = this.location,
host = this.domain;
this.old_route = this.current;
this.old_name = this.current_name;
this.old_match = this.match;
for(const route of this.__routes) {
if ( route.domain && route.domain !== host )
continue;
const match = route.regex.exec(path);
if ( match ) {
if ( match && (! route.state_fn || route.state_fn(this.current_state)) ) {
this.log.debug('Matching Route', route, match);
this.current = route;
this.current_name = route.name;
@ -146,12 +157,12 @@ export default class FineRouter extends Module {
this.emit(':updated-route-names');
}
route(name, path, domain = null, process = true) {
route(name, path, domain = null, state_fn = null, process = true) {
if ( typeof name === 'object' ) {
domain = path;
for(const key in name)
if ( has(name, key) )
this.route(key, name[key], domain, false);
this.route(key, name[key], domain, state_fn, false);
if ( process ) {
this.__routes.sort((a,b) => b.score - a.score);
@ -173,6 +184,7 @@ export default class FineRouter extends Module {
parts,
score,
domain,
state_fn,
regex: tokensToRegExp(parts),
url: tokensToFunction(parts)
}

View file

@ -4,7 +4,21 @@ query FFZ_FetchUser($id: ID, $login: String) {
login
displayName
profileImageURL(width: 50)
profileViewCount
primaryColorHex
broadcastSettings {
id
game {
id
displayName
}
}
stream {
id
}
followers {
totalCount
}
roles {
isAffiliate
isPartner

View file

@ -69,7 +69,7 @@ export const DEFAULT_TYPES = {
},
duration(val) {
return duration_to_string(val);
return this.formatDuration(val);
},
localestring(val) {
@ -257,6 +257,10 @@ export default class TranslationCore {
return formatter.format(value);
}
formatDuration(value) { // eslint-disable-line class-methods-use-this
return duration_to_string(value);
}
formatDate(value, format) {
if ( typeof format === 'string' && format.startsWith('::') ) {
const f = format.substr(2),