1
0
Fork 0
mirror of https://github.com/FrankerFaceZ/FrankerFaceZ.git synced 2025-07-05 10:38:30 +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:
SirStendec 2017-11-15 14:05:58 -05:00
parent 23e2fadba3
commit 1357a3e143
2 changed files with 26 additions and 25 deletions

View file

@ -55,30 +55,20 @@ export default class Scroller extends Module {
const old_freeze = this.freeze;
this.freeze = val;
for(const inst of this.ChatScroller.instances)
if ( val === 0 )
inst.ffzDisableFreeze();
else if ( old_freeze === 0 )
for(const inst of this.ChatScroller.instances) {
inst.ffzDisableFreeze();
if ( val !== 0 )
inst.ffzEnableFreeze();
else
inst.ffzUpdateText();
}
});
this.ChatScroller.ready((cls, instances) => {
const t = this;
const t = this,
old_scroll = cls.prototype.scrollToBottom;
cls.prototype.componentDidUpdate = function(props, state) {
if ( state.isAutoScrolling &&
! state.ffzFrozen &&
this.props.messages !== props.messages )
this.scrollToBottom();
}
const old_scroll = cls.prototype.scrollToBottom;
cls.prototype.scrollToBottom = function() {
if ( this.state.ffzFrozen )
this.setState({ffzFrozen: false});
return old_scroll.call(this);
if ( ! this.state.ffzFrozen )
return old_scroll.call(this);
}
cls.prototype.ffzShouldBeFrozen = function(since) {
@ -190,10 +180,12 @@ export default class Scroller extends Module {
this.ffz_freeze_enabled = true;
document.body.addEventListener('keydown',
this._ffz_key = this.ffzKey.bind(this));
if ( t.freeze > 1 ) {
document.body.addEventListener('keydown',
this._ffz_key = this.ffzKey.bind(this));
document.body.addEventListener('keyup', this._ffz_key);
document.body.addEventListener('keyup', this._ffz_key);
}
node.addEventListener('mousemove',
this._ffz_mousemove = this.ffzMouseMove.bind(this));