mirror of
https://github.com/FrankerFaceZ/FrankerFaceZ.git
synced 2025-08-08 07:10:54 +00:00
Simplify how the Chat Freeze feature is implemented to hopefully fix any FFZ-related bugs there. Also fix an issue with FFZ failing to load when there are extra React roots in the page.
This commit is contained in:
parent
23e2fadba3
commit
1357a3e143
2 changed files with 26 additions and 25 deletions
|
@ -21,14 +21,17 @@ export default class Fine extends Module {
|
|||
}
|
||||
|
||||
|
||||
async onEnable() {
|
||||
async onEnable(tries=0) {
|
||||
// TODO: Move awaitElement to utilities/dom
|
||||
if ( ! this.root_element )
|
||||
this.root_element = await this.parent.awaitElement(this.selector || '[data-reactroot]');
|
||||
this.root_element = await this.parent.awaitElement(this.selector || '#root [data-reactroot]');
|
||||
|
||||
const accessor = this.accessor = Fine.findAccessor(this.root_element);
|
||||
if ( ! accessor )
|
||||
return new Promise(r => setTimeout(r, 50)).then(() => this.onEnable());
|
||||
if ( ! accessor ) {
|
||||
if ( tries > 500 )
|
||||
throw new Error(`unable to find React after 25 seconds`);
|
||||
return new Promise(r => setTimeout(r, 50)).then(() => this.onEnable(tries+1));
|
||||
}
|
||||
|
||||
this.react = this.getReactInstance(this.root_element);
|
||||
}
|
||||
|
@ -449,6 +452,12 @@ export class FineWrapper extends EventEmitter {
|
|||
}
|
||||
|
||||
|
||||
forceUpdate() {
|
||||
for(const inst of this.instances)
|
||||
inst.forceUpdate();
|
||||
}
|
||||
|
||||
|
||||
on(event, fn, ctx) {
|
||||
this._maybeWrap(event);
|
||||
return super.on(event, fn, ctx);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue