diff --git a/src/main.js b/src/main.js index 1faef045..2b751281 100644 --- a/src/main.js +++ b/src/main.js @@ -149,7 +149,7 @@ ${typeof x[1] === 'string' ? x[1] : JSON.stringify(x[1], null, 4)}` FrankerFaceZ.Logger = Logger; 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__, build: __webpack_hash__, toString: () => diff --git a/src/sites/twitch-twilight/modules/chat/index.js b/src/sites/twitch-twilight/modules/chat/index.js index d522718e..bd480571 100644 --- a/src/sites/twitch-twilight/modules/chat/index.js +++ b/src/sites/twitch-twilight/modules/chat/index.js @@ -560,12 +560,25 @@ export default class ChatHook extends Module { this.ChatContainer.on('mount', this.containerMounted, 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) => { const t = this, + old_render = cls.prototype.render, 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 // recover from the error when we re-build? cls.prototype.componentDidCatch = function(err, info) { @@ -580,6 +593,7 @@ export default class ChatHook extends Module { return old_catch.call(this, err, info); } + for(const inst of instances) this.containerMounted(inst); }); @@ -1422,7 +1436,7 @@ export default class ChatHook extends Module { if ( chat.chatBuffer ) 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); if ( chat._ffz_mounted ) this.chatMounted(chat, props); @@ -1526,7 +1540,7 @@ export default class ChatHook extends Module { 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); if ( cont._ffz_mounted ) this.containerMounted(cont, props); diff --git a/src/utilities/compat/fine.js b/src/utilities/compat/fine.js index 7ec18b02..57dbf94f 100644 --- a/src/utilities/compat/fine.js +++ b/src/utilities/compat/fine.js @@ -148,7 +148,7 @@ export default class Fine extends Module { else if ( node instanceof Node ) node = this.getReactInstance(node); - if ( ! node || depth > max_depth ) + if ( ! node || node._ffz_no_scan || depth > max_depth ) return null; if ( typeof criteria === 'string' ) { @@ -195,7 +195,7 @@ export default class Fine extends Module { else if ( node instanceof Node ) node = this.getReactInstance(node); - if ( ! node || depth > max_depth ) + if ( ! node || node._ffz_no_scan || depth > max_depth ) return null; if ( typeof criteria === 'string' ) { @@ -257,7 +257,7 @@ export default class Fine extends Module { max_depth: depth }; - if ( ! node || depth > max_depth ) + if ( ! node || node._ffz_no_scan || depth > max_depth ) return data.out; if ( depth > data.max_depth ) @@ -458,12 +458,12 @@ export default class Fine extends Module { const EVENTS = { - 'will-mount': 'componentWillMount', + 'will-mount': 'UNSAFE_componentWillMount', mount: 'componentDidMount', render: 'render', - 'receive-props': 'componentWillReceiveProps', + 'receive-props': 'UNSAFE_componentWillReceiveProps', 'should-update': 'shouldComponentUpdate', - 'will-update': 'componentWillUpdate', + 'will-update': 'UNSAFE_componentWillUpdate', update: 'componentDidUpdate', unmount: 'componentWillUnmount' } @@ -504,16 +504,16 @@ export class FineWrapper extends EventEmitter { throw new Error('already have a class'); this._class = cls; - this._wrapped.add('componentWillMount'); + this._wrapped.add('UNSAFE_componentWillMount'); this._wrapped.add('componentWillUnmount'); const t = this, _instances = this.instances, proto = cls.prototype, - o_mount = proto.componentWillMount, + o_mount = proto.UNSAFE_componentWillMount, o_unmount = proto.componentWillUnmount, - mount = proto.componentWillMount = o_mount ? + mount = proto.UNSAFE_componentWillMount = o_mount ? function(...args) { this._ffz_mounted = true; _instances.add(this); @@ -539,7 +539,7 @@ export class FineWrapper extends EventEmitter { this._ffz_mounted = false; }; - this.__componentWillMount = [mount, o_mount]; + this.__UNSAFE_componentWillMount = [mount, o_mount]; this.__componentWillUnmount = [unmount, o_unmount]; for(const event of this.events()) @@ -580,17 +580,35 @@ export class FineWrapper extends EventEmitter { fn = proto[key] = original ? function(...args) { + if ( ! this._ffz_mounted ) { + this._ffz_mounted = true; + t.instances.add(this); + t.emit('late-mount', this); + } + t.emit(event, this, ...args); return original.apply(this, args); } : key === 'shouldComponentUpdate' ? function(...args) { + if ( ! this._ffz_mounted ) { + this._ffz_mounted = true; + t.instances.add(this); + t.emit('late-mount', this); + } + t.emit(event, this, ...args); return true; } : function(...args) { + if ( ! this._ffz_mounted ) { + this._ffz_mounted = true; + t.instances.add(this); + t.emit('late-mount', this); + } + t.emit(event, this, ...args); };