1
0
Fork 0
mirror of https://github.com/FrankerFaceZ/FrankerFaceZ.git synced 2025-07-24 19:48:30 +00:00

3.5.311. Fix the page scrolling when you open the FFZ menu's sections. Closes #18. Properly fix message doubling.

This commit is contained in:
SirStendec 2016-10-04 14:10:59 -04:00
parent 91e8cb5739
commit 26a55b169f
5 changed files with 55 additions and 25 deletions

View file

@ -1,3 +1,9 @@
<div class="list-header">3.5.311 <time datetime="2016-10-03">(2016-10-04)</time></div>
<ul class="chat-menu-content menu-side-padding">
<li>Fixed: Opening sections of the FFZ settings menu could cause the page to scroll oddly in a way that's not easily fixed.</li>
<li>Updated Fix: Message Doubling. Properly check a message's <code>hasSystemMsg</code> property as <code>systemMsg</code> will always contain a string now.</li>
</ul>
<div class="list-header">3.5.310 <time datetime="2016-10-03">(2016-10-04)</time></div>
<ul class="chat-menu-content menu-side-padding">
<li>Fixed: Twitch broke message handling by deciding <em>every</em> message is a system message. I'll fix it properly later.</li>

View file

@ -828,18 +828,14 @@ FFZ.prototype._modify_chat_line = function(component, is_vod) {
return '<span class="' + (is_recipient ? 'to' : 'from') + (alias ? ' ffz-alias' : '') + (results[1] ? ' html-tooltip' : '') + colored + '" style="' + style + (colors ? '" data-color="' + raw_color : '') + (results[1] ? '" title="' + utils.quote_attr(results[1]) : '') + '">' + results[0] + '</span>';
},
buildSystemMessageHTML: function() {
return this.get('hasSystemMsg') ?
'<div class="system-msg">' + utils.sanitize(this.get('systemMsg')) + '</div>' :
'';
},
buildSenderHTML: function() {
var system_msg = this.get('systemMsg'),
output = '';
output = '<div class="indicator"></div>';
// System Message
if ( system_msg ) {
output += '<div class="system-msg">' + utils.sanitize(system_msg) + '</div>';
if ( this.get('ffzShouldRenderMessageBody') === false )
return output;
}
var output = '';
// Timestamp
var timestamp = this.get('timestamp');
@ -900,29 +896,31 @@ FFZ.prototype._modify_chat_line = function(component, is_vod) {
ffzRender: function() {
var el = this.get('element'),
output = this.buildSenderHTML();
output = '<div class="indicator"></div>';
// If this is a whisper, or if we should render the message body, render it.
if ( this.get('ffzShouldRenderMessageBody') !== false )
if ( this.get('msgObject.deleted') )
output += this.buildDeletedMessageHTML()
else
output += this.buildMessageHTML();
output += this.buildSystemMessageHTML();
if ( this.get('ffzShouldRenderMessageBody') ) {
output += this.buildSenderHTML();
output += this.get('msgObject.deleted') ?
this.buildDeletedMesageHTML() : this.buildMessageHTML();
}
el.innerHTML = output;
},
ffzShouldRenderMessageBody: function() {
return ! this.get('hasSystemMsg') || this.get('hasMessageBody');
return !this.get("hasSystemMsg") || this.get("hasMessageBody");
}.property('hasSystemMsg', 'hasMessageBody'),
systemMsg: function() {
return this.get('msgObject.tags.system-msg')
hasSystemMsg: function() {
var msg = this.get('msgObject.tags.system-msg');
return msg && msg.length > 0;
}.property('msgObject.tags.system-msg'),
//shouldRenderMessageBody: function() {
// return false;
//}.property('hasSystemMsg', 'hasMessageBody'),
shouldRenderMessageBody: function() {
return false;
}.property(),
ffzWasDeleted: function() {
return f.settings.prevent_clear && this.get("msgObject.ffz_deleted")

View file

@ -23,6 +23,10 @@ FFZ.prototype.setup_router = function() {
return;
}
// If we're coming from a page without app-main, make sure we install the
// scroll listener.
f.fix_scroll();
try {
document.body.setAttribute('data-current-path', App.get('currentPath'));
} catch(err) {

View file

@ -34,7 +34,7 @@ FFZ.msg_commands = {};
// Version
var VER = FFZ.version_info = {
major: 3, minor: 5, revision: 310,
major: 3, minor: 5, revision: 311,
toString: function() {
return [VER.major, VER.minor, VER.revision].join(".") + (VER.extra || "");
}
@ -510,6 +510,7 @@ FFZ.prototype.init_ember = function(delay) {
this.cache_command_aliases();
this.fix_tooltips();
this.fix_scroll();
this.connect_extra_chat();
this.setup_message_event();

View file

@ -43,6 +43,27 @@ FFZ.prototype.setup_css = function() {
}
FFZ.prototype._scroll_fixed = null;
FFZ.prototype.fix_scroll = function() {
if ( this._scroll_fixed )
return;
var f = this,
main = document.querySelector('.app-main');
if ( main ) {
this._scroll_fixed = true;
main.addEventListener('scroll', function() {
if ( this.scrollTop !== 0 ) {
f.log("The application scrolled wrongly. Correcting.");
this.scrollTop = 0;
}
});
}
}
FFZ.prototype.toggle_style = function(key, enabled) {
var state = this._toggle_style_state[key];
if ( (enabled && state) || (!enabled && !state) )