mirror of
https://github.com/FrankerFaceZ/FrankerFaceZ.git
synced 2025-10-14 06:51:58 +00:00
Add experiments system. Add experiments UI. Update disabled buttons to use tw-button--disabled. Update chat line rendering. Add preset emote sizes to the emote menu to reduce reflows when loading. Fix directory issues caused by fixes to route sorting. Update the theme. Add a current route name value to fine router. Add recursive object protection to deep_copy.
This commit is contained in:
parent
1841ab156c
commit
e3a7e3b64d
35 changed files with 1075 additions and 451 deletions
|
@ -136,13 +136,14 @@ export default class Apollo extends Module {
|
|||
query = query_map && query_map.get(id),
|
||||
modifiers = this.modifiers[operation];
|
||||
|
||||
if ( modifiers )
|
||||
if ( modifiers ) {
|
||||
for(const mod of modifiers) {
|
||||
if ( typeof mod === 'function' )
|
||||
mod(request);
|
||||
else if ( mod[1] )
|
||||
this.applyModifier(request, mod[1]);
|
||||
}
|
||||
}
|
||||
|
||||
this.emit(`:request.${operation}`, request.query, request.variables);
|
||||
|
||||
|
@ -358,18 +359,23 @@ function merge(a, b) {
|
|||
const s = a.selectionSet.selections,
|
||||
selects = {};
|
||||
for(const sel of b.selectionSet.selections) {
|
||||
if (sel.name && sel.name.value) {
|
||||
selects[`${sel.name.value}:${sel.alias?sel.alias.value:null}`] = sel;
|
||||
} else {
|
||||
if (sel.kind === 'InlineFragment') {
|
||||
selects[`${sel.typeCondition.name.value}:${sel.alias?sel.alias.value:null}`] = sel;
|
||||
}
|
||||
}
|
||||
const name = sel.kind === 'InlineFragment' ?
|
||||
(sel.typeCondition.name ?
|
||||
sel.typeCondition.name.value : null) :
|
||||
(sel.name ? sel.name.value : null),
|
||||
alias = sel.alias ? sel.alias.value : null,
|
||||
key = `${name}:${alias}`;
|
||||
|
||||
if ( name )
|
||||
selects[key] = sel;
|
||||
}
|
||||
|
||||
for(let i=0, l = s.length; i < l; i++) {
|
||||
const sel = s[i],
|
||||
name = sel.kind === 'InlineFragment' ? (sel.typeCondition.name ? sel.typeCondition.name.value : null) : (sel.name ? sel.name.value : null),
|
||||
name = sel.kind === 'InlineFragment' ?
|
||||
(sel.typeCondition.name ?
|
||||
sel.typeCondition.name.value : null) :
|
||||
(sel.name ? sel.name.value : null),
|
||||
alias = sel.alias ? sel.alias.value : null,
|
||||
key = `${name}:${alias}`,
|
||||
other = selects[key];
|
||||
|
|
|
@ -17,6 +17,7 @@ export default class FineRouter extends Module {
|
|||
this.__routes = [];
|
||||
this.routes = {};
|
||||
this.current = null;
|
||||
this.current_name = null;
|
||||
this.match = null;
|
||||
this.location = null;
|
||||
}
|
||||
|
@ -58,6 +59,7 @@ export default class FineRouter extends Module {
|
|||
if ( match ) {
|
||||
this.log.debug('Matching Route', route, match);
|
||||
this.current = route;
|
||||
this.current_name = route.name;
|
||||
this.match = match;
|
||||
this.emitSafe(':route', route, match);
|
||||
this.emitSafe(`:route:${route.name}`, ...match);
|
||||
|
@ -65,7 +67,7 @@ export default class FineRouter extends Module {
|
|||
}
|
||||
}
|
||||
|
||||
this.current = this.match = null;
|
||||
this.current = this.current_name = this.match = null;
|
||||
this.emitSafe(':route', null, null);
|
||||
}
|
||||
|
||||
|
|
|
@ -185,19 +185,27 @@ export function get(path, object) {
|
|||
}
|
||||
|
||||
|
||||
export function deep_copy(object) {
|
||||
export function deep_copy(object, seen) {
|
||||
if ( typeof object !== 'object' )
|
||||
return object;
|
||||
|
||||
if ( ! seen )
|
||||
seen = new Set;
|
||||
|
||||
if ( seen.has(object) )
|
||||
throw new Error('recursive structure detected');
|
||||
|
||||
seen.add(object);
|
||||
|
||||
if ( Array.isArray(object) )
|
||||
return object.map(deep_copy);
|
||||
return object.map(x => deep_copy(x, seen));
|
||||
|
||||
const out = {};
|
||||
for(const key in object)
|
||||
if ( HOP.call(object, key) ) {
|
||||
const val = object[key];
|
||||
if ( typeof val === 'object' )
|
||||
out[key] = deep_copy(val);
|
||||
out[key] = deep_copy(val, seen);
|
||||
else
|
||||
out[key] = val;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue