mirror of
https://github.com/FrankerFaceZ/FrankerFaceZ.git
synced 2025-07-05 18:48:31 +00:00
4.0.0-rc19.4
* Changed: Better DOM scanning performance by giving up faster. * Fixed: More stupid changes in order to force events to fire on the component we grab badge data from.
This commit is contained in:
parent
ebc671ae1e
commit
c920b43e01
3 changed files with 46 additions and 14 deletions
|
@ -149,7 +149,7 @@ ${typeof x[1] === 'string' ? x[1] : JSON.stringify(x[1], null, 4)}`
|
||||||
FrankerFaceZ.Logger = Logger;
|
FrankerFaceZ.Logger = Logger;
|
||||||
|
|
||||||
const VER = FrankerFaceZ.version_info = {
|
const VER = FrankerFaceZ.version_info = {
|
||||||
major: 4, minor: 0, revision: 0, extra: '-rc19.3',
|
major: 4, minor: 0, revision: 0, extra: '-rc19.4',
|
||||||
commit: __git_commit__,
|
commit: __git_commit__,
|
||||||
build: __webpack_hash__,
|
build: __webpack_hash__,
|
||||||
toString: () =>
|
toString: () =>
|
||||||
|
|
|
@ -560,12 +560,25 @@ export default class ChatHook extends Module {
|
||||||
|
|
||||||
this.ChatContainer.on('mount', this.containerMounted, this);
|
this.ChatContainer.on('mount', this.containerMounted, this);
|
||||||
this.ChatContainer.on('unmount', this.removeRoom, this);
|
this.ChatContainer.on('unmount', this.removeRoom, this);
|
||||||
this.ChatContainer.on('update', this.containerUpdated, this);
|
this.ChatContainer.on('receive-props', this.containerUpdated, this);
|
||||||
|
|
||||||
this.ChatContainer.ready((cls, instances) => {
|
this.ChatContainer.ready((cls, instances) => {
|
||||||
const t = this,
|
const t = this,
|
||||||
|
old_render = cls.prototype.render,
|
||||||
old_catch = cls.prototype.componentDidCatch;
|
old_catch = cls.prototype.componentDidCatch;
|
||||||
|
|
||||||
|
// This is so stupid. I hate React. Why won't the events just fire
|
||||||
|
// like they should.
|
||||||
|
cls.prototype.render = function() {
|
||||||
|
try {
|
||||||
|
t.containerUpdated(this, this.props);
|
||||||
|
} catch(err) {
|
||||||
|
t.log.error(err);
|
||||||
|
}
|
||||||
|
|
||||||
|
return old_render.call(this);
|
||||||
|
}
|
||||||
|
|
||||||
// Try catching errors. With any luck, maybe we can
|
// Try catching errors. With any luck, maybe we can
|
||||||
// recover from the error when we re-build?
|
// recover from the error when we re-build?
|
||||||
cls.prototype.componentDidCatch = function(err, info) {
|
cls.prototype.componentDidCatch = function(err, info) {
|
||||||
|
@ -580,6 +593,7 @@ export default class ChatHook extends Module {
|
||||||
return old_catch.call(this, err, info);
|
return old_catch.call(this, err, info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
for(const inst of instances)
|
for(const inst of instances)
|
||||||
this.containerMounted(inst);
|
this.containerMounted(inst);
|
||||||
});
|
});
|
||||||
|
@ -1422,7 +1436,7 @@ export default class ChatHook extends Module {
|
||||||
if ( chat.chatBuffer )
|
if ( chat.chatBuffer )
|
||||||
chat.chatBuffer.ffzController = chat;
|
chat.chatBuffer.ffzController = chat;
|
||||||
|
|
||||||
if ( ! chat._ffz_room || props.channelID !== chat.props.channelID ) {
|
if ( ! chat._ffz_room || props.channelID != chat._ffz_room.id ) {
|
||||||
this.removeRoom(chat);
|
this.removeRoom(chat);
|
||||||
if ( chat._ffz_mounted )
|
if ( chat._ffz_mounted )
|
||||||
this.chatMounted(chat, props);
|
this.chatMounted(chat, props);
|
||||||
|
@ -1526,7 +1540,7 @@ export default class ChatHook extends Module {
|
||||||
|
|
||||||
|
|
||||||
containerUpdated(cont, props) {
|
containerUpdated(cont, props) {
|
||||||
if ( ! cont._ffz_room || props.channelID !== cont.props.channelID ) {
|
if ( ! cont._ffz_room || props.channelID != cont._ffz_room.id ) {
|
||||||
this.removeRoom(cont);
|
this.removeRoom(cont);
|
||||||
if ( cont._ffz_mounted )
|
if ( cont._ffz_mounted )
|
||||||
this.containerMounted(cont, props);
|
this.containerMounted(cont, props);
|
||||||
|
|
|
@ -148,7 +148,7 @@ export default class Fine extends Module {
|
||||||
else if ( node instanceof Node )
|
else if ( node instanceof Node )
|
||||||
node = this.getReactInstance(node);
|
node = this.getReactInstance(node);
|
||||||
|
|
||||||
if ( ! node || depth > max_depth )
|
if ( ! node || node._ffz_no_scan || depth > max_depth )
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
if ( typeof criteria === 'string' ) {
|
if ( typeof criteria === 'string' ) {
|
||||||
|
@ -195,7 +195,7 @@ export default class Fine extends Module {
|
||||||
else if ( node instanceof Node )
|
else if ( node instanceof Node )
|
||||||
node = this.getReactInstance(node);
|
node = this.getReactInstance(node);
|
||||||
|
|
||||||
if ( ! node || depth > max_depth )
|
if ( ! node || node._ffz_no_scan || depth > max_depth )
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
if ( typeof criteria === 'string' ) {
|
if ( typeof criteria === 'string' ) {
|
||||||
|
@ -257,7 +257,7 @@ export default class Fine extends Module {
|
||||||
max_depth: depth
|
max_depth: depth
|
||||||
};
|
};
|
||||||
|
|
||||||
if ( ! node || depth > max_depth )
|
if ( ! node || node._ffz_no_scan || depth > max_depth )
|
||||||
return data.out;
|
return data.out;
|
||||||
|
|
||||||
if ( depth > data.max_depth )
|
if ( depth > data.max_depth )
|
||||||
|
@ -458,12 +458,12 @@ export default class Fine extends Module {
|
||||||
|
|
||||||
|
|
||||||
const EVENTS = {
|
const EVENTS = {
|
||||||
'will-mount': 'componentWillMount',
|
'will-mount': 'UNSAFE_componentWillMount',
|
||||||
mount: 'componentDidMount',
|
mount: 'componentDidMount',
|
||||||
render: 'render',
|
render: 'render',
|
||||||
'receive-props': 'componentWillReceiveProps',
|
'receive-props': 'UNSAFE_componentWillReceiveProps',
|
||||||
'should-update': 'shouldComponentUpdate',
|
'should-update': 'shouldComponentUpdate',
|
||||||
'will-update': 'componentWillUpdate',
|
'will-update': 'UNSAFE_componentWillUpdate',
|
||||||
update: 'componentDidUpdate',
|
update: 'componentDidUpdate',
|
||||||
unmount: 'componentWillUnmount'
|
unmount: 'componentWillUnmount'
|
||||||
}
|
}
|
||||||
|
@ -504,16 +504,16 @@ export class FineWrapper extends EventEmitter {
|
||||||
throw new Error('already have a class');
|
throw new Error('already have a class');
|
||||||
|
|
||||||
this._class = cls;
|
this._class = cls;
|
||||||
this._wrapped.add('componentWillMount');
|
this._wrapped.add('UNSAFE_componentWillMount');
|
||||||
this._wrapped.add('componentWillUnmount');
|
this._wrapped.add('componentWillUnmount');
|
||||||
|
|
||||||
const t = this,
|
const t = this,
|
||||||
_instances = this.instances,
|
_instances = this.instances,
|
||||||
proto = cls.prototype,
|
proto = cls.prototype,
|
||||||
o_mount = proto.componentWillMount,
|
o_mount = proto.UNSAFE_componentWillMount,
|
||||||
o_unmount = proto.componentWillUnmount,
|
o_unmount = proto.componentWillUnmount,
|
||||||
|
|
||||||
mount = proto.componentWillMount = o_mount ?
|
mount = proto.UNSAFE_componentWillMount = o_mount ?
|
||||||
function(...args) {
|
function(...args) {
|
||||||
this._ffz_mounted = true;
|
this._ffz_mounted = true;
|
||||||
_instances.add(this);
|
_instances.add(this);
|
||||||
|
@ -539,7 +539,7 @@ export class FineWrapper extends EventEmitter {
|
||||||
this._ffz_mounted = false;
|
this._ffz_mounted = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
this.__componentWillMount = [mount, o_mount];
|
this.__UNSAFE_componentWillMount = [mount, o_mount];
|
||||||
this.__componentWillUnmount = [unmount, o_unmount];
|
this.__componentWillUnmount = [unmount, o_unmount];
|
||||||
|
|
||||||
for(const event of this.events())
|
for(const event of this.events())
|
||||||
|
@ -580,17 +580,35 @@ export class FineWrapper extends EventEmitter {
|
||||||
|
|
||||||
fn = proto[key] = original ?
|
fn = proto[key] = original ?
|
||||||
function(...args) {
|
function(...args) {
|
||||||
|
if ( ! this._ffz_mounted ) {
|
||||||
|
this._ffz_mounted = true;
|
||||||
|
t.instances.add(this);
|
||||||
|
t.emit('late-mount', this);
|
||||||
|
}
|
||||||
|
|
||||||
t.emit(event, this, ...args);
|
t.emit(event, this, ...args);
|
||||||
return original.apply(this, args);
|
return original.apply(this, args);
|
||||||
} :
|
} :
|
||||||
|
|
||||||
key === 'shouldComponentUpdate' ?
|
key === 'shouldComponentUpdate' ?
|
||||||
function(...args) {
|
function(...args) {
|
||||||
|
if ( ! this._ffz_mounted ) {
|
||||||
|
this._ffz_mounted = true;
|
||||||
|
t.instances.add(this);
|
||||||
|
t.emit('late-mount', this);
|
||||||
|
}
|
||||||
|
|
||||||
t.emit(event, this, ...args);
|
t.emit(event, this, ...args);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
:
|
:
|
||||||
function(...args) {
|
function(...args) {
|
||||||
|
if ( ! this._ffz_mounted ) {
|
||||||
|
this._ffz_mounted = true;
|
||||||
|
t.instances.add(this);
|
||||||
|
t.emit('late-mount', this);
|
||||||
|
}
|
||||||
|
|
||||||
t.emit(event, this, ...args);
|
t.emit(event, this, ...args);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue