mirror of
https://github.com/FrankerFaceZ/FrankerFaceZ.git
synced 2025-10-15 07:21:58 +00:00
Clean up a bunch of linting stuff. Clean up event listeners in tooltips to stop potential memory leaks.
This commit is contained in:
parent
f506b512b4
commit
7ecd45fcfb
23 changed files with 70 additions and 79 deletions
|
@ -19,7 +19,7 @@ export default class Apollo extends Module {
|
|||
this.inject('..fine');
|
||||
}
|
||||
|
||||
async onEnable() {
|
||||
onEnable() {
|
||||
// TODO: Come up with a better way to await something existing.
|
||||
let client = this.client;
|
||||
|
||||
|
@ -48,7 +48,7 @@ export default class Apollo extends Module {
|
|||
const old_qm_init = this.client.queryManager.queryStore.initQuery;
|
||||
this.hooked_query_init = true;
|
||||
this.client.queryManager.queryStore.initQuery = function(e) {
|
||||
let t = this.store[e.queryId];
|
||||
const t = this.store[e.queryId];
|
||||
if ( t && t.queryString !== e.queryString )
|
||||
t.queryString = e.queryString;
|
||||
|
||||
|
@ -59,7 +59,8 @@ export default class Apollo extends Module {
|
|||
const ApolloLink = this.ApolloLink = this.client.link.constructor;
|
||||
|
||||
this.link = new ApolloLink((operation, forward) => {
|
||||
//this.log.info('Link Start', operation.operationName, operation);
|
||||
if ( ! this.enabled )
|
||||
return forward(operation);
|
||||
|
||||
try {
|
||||
// ONLY do this if we've hooked query init, thus letting us ignore certain issues
|
||||
|
@ -120,23 +121,8 @@ export default class Apollo extends Module {
|
|||
|
||||
|
||||
onDisable() {
|
||||
// TODO: Remove Apollo middleware.
|
||||
|
||||
// Tear down the parsed queries.
|
||||
for(const key in this.modifiers)
|
||||
if ( has(this.modifiers, key) ) {
|
||||
const modifiers = this.modifiers[key];
|
||||
if ( modifiers )
|
||||
for(const mod of modifiers) {
|
||||
if ( typeof mod === 'function' )
|
||||
continue;
|
||||
|
||||
mod[1] = null;
|
||||
}
|
||||
}
|
||||
|
||||
// And finally, remove our references.
|
||||
this.client = this.graphql = null;
|
||||
// Remove our references to things.
|
||||
this.client = this.printer = this.gql_print = this.old_link = this.old_qm_dedup = this.old_qm_link = null;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -135,7 +135,7 @@ export class ManagedStyle {
|
|||
}
|
||||
|
||||
set(key, value) {
|
||||
let block = this._blocks[key];
|
||||
const block = this._blocks[key];
|
||||
if ( block )
|
||||
block.textContent = value;
|
||||
else
|
||||
|
|
|
@ -521,9 +521,9 @@ export class Module extends EventEmitter {
|
|||
for(const raw_path of ctx.keys()) {
|
||||
const raw_module = ctx(raw_path),
|
||||
module = raw_module.module || raw_module.default,
|
||||
name = raw_path.slice(2, raw_path.length - (raw_path.endsWith('/index.jsx') ? 10 : raw_path.endsWith('/index.js') ? 9 : raw_path.endsWith('.jsx') ? 4 : 3));
|
||||
|
||||
// TODO: rewrite the name code to not have like 4 endsWith in it.
|
||||
lix = raw_path.lastIndexOf('.'),
|
||||
trimmed = lix > 2 ? raw_path.slice(2, lix) : raw_path,
|
||||
name = trimmed.endsWith('/index') ? trimmed.slice(0, -6) : trimmed;
|
||||
|
||||
try {
|
||||
added[name] = this.register(name, module);
|
||||
|
|
|
@ -229,7 +229,7 @@ export class Tooltip {
|
|||
el.classList.toggle('interactive', interactive || false);
|
||||
|
||||
if ( ! opts.manual ) {
|
||||
el.addEventListener('mouseover', () => {
|
||||
el.addEventListener('mouseover', el._ffz_over_handler = () => {
|
||||
if ( ! document.contains(target) )
|
||||
this.hide(tip);
|
||||
|
||||
|
@ -239,7 +239,7 @@ export class Tooltip {
|
|||
this._exit(target);
|
||||
});
|
||||
|
||||
el.addEventListener('mouseout', () => this._exit(target));
|
||||
el.addEventListener('mouseout', el._ffz_out_handler = () => this._exit(target));
|
||||
}
|
||||
|
||||
// Assign our content. If there's a Promise, we'll need
|
||||
|
@ -311,13 +311,19 @@ export class Tooltip {
|
|||
}
|
||||
|
||||
if ( tip.outer ) {
|
||||
tip.outer.remove();
|
||||
tip.outer = null;
|
||||
const el = tip.outer;
|
||||
if ( el._ffz_over_handler )
|
||||
el.removeEventListener('mouseover', el._ffz_over_handler);
|
||||
|
||||
if ( el._ffz_out_handler )
|
||||
el.removeEventListener('mouseout', el._ffz_out_handler);
|
||||
|
||||
el.remove();
|
||||
tip.outer = el._ffz_out_handler = el._ffz_over_handler = null;
|
||||
}
|
||||
|
||||
tip.update = null;
|
||||
tip._update = noop;
|
||||
tip.element = null;
|
||||
tip.update = tip.element = null;
|
||||
tip.visible = false;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue