1
0
Fork 0
mirror of https://github.com/FrankerFaceZ/FrankerFaceZ.git synced 2025-09-17 18:26:57 +00:00

3.5.405. API additions. Improve support for follower-only chat mode. Fix whispers in pop-out chat. Fix a compatibility issue with BetterTTV. Fix channel metadata on theater mode hover. Fix Twitch's most recent changes to player positioning. Fix classic player control height in theater mode. Closes #72

This commit is contained in:
SirStendec 2016-12-19 21:33:45 -05:00
parent 5166784eb0
commit 1b9b695bdd
11 changed files with 186 additions and 106 deletions

View file

@ -193,9 +193,11 @@ FFZ.prototype.modify_channel_live = function(view) {
},
ffzUpdatePlayerPosition: function() {
if ( this._ffz_player_repositoner && Date.now() - this._ffz_loaded > 60000 ) {
if ( f.has_bttv || this._ffz_player_repositoner && Date.now() - this._ffz_loaded > 60000 ) {
clearInterval(this._ffz_player_repositoner);
this._ffz_player_repositoner = null;
if ( f.has_bttv )
return;
}
this.updatePlayerPosition();

View file

@ -29,11 +29,11 @@ var FFZ = window.FrankerFaceZ,
},
slowoff: {info: 'Disable Slow Mode'},
/*followers: {
label: '/followers <i>[duration followed]</i>',
followers: {
label: '/followers <i>[duration]</i>',
info: 'Enable Followers-Only Mode'
},
followersoff: { info: 'Disable Followers-Only Mode'},*/
followersoff: { info: 'Disable Followers-Only Mode'},
r9kbeta: {info: 'Enable R9k Mode'},
r9kbetaoff: {info: 'Disable R9k Mode'},

View file

@ -679,10 +679,10 @@ FFZ.prototype.setup_line = function() {
this.toggle_style('chat-hc-bold', this.settings.high_contrast_chat[1] === '1');
this.toggle_style('chat-hc-background', this.settings.high_contrast_chat[0] === '1');
var f = this;
this.update_views('component:video/rechat/chat-message', this._modify_vod_line);
this.update_views('component:chat/message-line', this._modify_chat_subline);
this.update_views('component:chat/whisper-line', this._modify_chat_subline);
this.update_views('component:chat/whisper-line', function(x) { return f._modify_chat_subline(x, true) });
// Store the capitalization of our own name.
@ -773,7 +773,7 @@ FFZ.prototype._modify_chat_line = function(component, is_vod) {
this_ul = this.get('ffzUserLevel'),
other_ul = room && room.room && room.room.get('ffzUserLevel') || 0,
shouldnt_show =is_whisper || this_ul >= other_ul || (f.settings.mod_buttons.length === 0 && ! is_tb),
shouldnt_show = is_whisper || this_ul >= other_ul || (f.settings.mod_buttons.length === 0 && ! is_tb),
output;
if ( ! is_pinned_cheer && shouldnt_show )
@ -976,15 +976,19 @@ FFZ.prototype._modify_chat_line = function(component, is_vod) {
}
FFZ.prototype._modify_chat_subline = function(component) {
FFZ.prototype._modify_chat_subline = function(component, is_whisper) {
var f = this,
PinnedCheers = utils.ember_lookup('service:bits-pinned-cheers');
this._modify_chat_line(component);
component.reopen({
classNameBindings: ["msgObject.style", "msgObject.isModerationMessage:moderation-message", "msgObject.ffz_has_mention:ffz-mentioned", "ffzWasDeleted:ffz-deleted", "ffzHasOldMessages:clearfix", "ffzHasOldMessages:ffz-has-deleted"],
attributeBindings: ["msgObject.tags.id:data-id", "msgObject.room:data-room", "msgObject.from:data-sender", "msgObject.deleted:data-deleted"],
classNameBindings: is_whisper ?
[':whisper-line', ':chat-line', 'isReceivedWhisper:whisper-incoming:whisper-outgoing'] :
["msgObject.style", "msgObject.isModerationMessage:moderation-message", "msgObject.ffz_has_mention:ffz-mentioned", "ffzWasDeleted:ffz-deleted", "ffzHasOldMessages:clearfix", "ffzHasOldMessages:ffz-has-deleted"],
attributeBindings: is_whisper ?
['msgObject.nonce:data-nonce', 'msgObject.tags.id:data-id', 'msgObject.from:data-sender'] :
["msgObject.tags.id:data-id", "msgObject.room:data-room", "msgObject.from:data-sender", "msgObject.deleted:data-deleted"],
didInsertElement: function() {
if ( this.get('msgObject') ) {

View file

@ -23,10 +23,11 @@ var FFZ = window.FrankerFaceZ,
["emote", "emoteOnly", "This room is in Twitch emoticons only mode. Emoticons added by extensions are not available in this mode."],
["sub", "subsOnly", "This room is in subscribers-only mode."],
["follow", function(room) {
return room && room.get('followersOnly') > -1
return room && ! room.get('isGroupRoom') && room.get('followersOnly') > -1
}, function(room) {
var name = room && (room.get('channel.display_name') || room.get("tmiRoom.displayName") || room.get('isGroupRoom') ? room.get('tmiRoom.name') : FFZ.get_capitalization(room.get('name')) );
return "This room is in followers-only mode. You may only participate in chat if you have been following " + utils.sanitize(name) + " for at least " + utils.duration_string((room && room.get('followersOnly') || 0) * 60, true, true) + "."
var name = room && (room.get('channel.display_name') || room.get("tmiRoom.displayName") || room.get('isGroupRoom') ? room.get('tmiRoom.name') : FFZ.get_capitalization(room.get('name')) ),
duration = room && room.get('followersOnly') || 0;
return "This room is in followers-only mode. You may only participate in chat if you " + (duration > 0 ? " have been following " : 'follow ') + utils.sanitize(name) + (duration > 0 ? " for at least " + utils.duration_string(duration * 60, true, true) : '') + ".";
}],
["slow", "slow", function(room) { return "This room is in slow mode. You may send messages every <nobr>" + utils.number_commas(room && room.get('slow') || 120) + " seconds</nobr>." }],
["ban", "ffz_banned", "You have been banned from talking in this room."],
@ -999,12 +1000,16 @@ FFZ.prototype.add_room = function(room_id, room) {
if ( set ) {
if ( set.users.indexOf(room_id) === -1 )
set.users.push(room_id);
room.ffzRetokenizeUser();
continue;
}
this.load_set(sid, function(success, data) {
if ( success )
data.users.push(room_id);
if ( success ) {
if ( data.users.indexOf(room_id) === -1 )
data.users.push(room_id);
room.ffzRetokenizeUser();
}
});
}
}
@ -1260,7 +1265,7 @@ FFZ.prototype._modify_room = function(room) {
ffzUpdateStatus: function() {
if ( f._roomv )
f._roomv.ffzUpdateStatus();
}.observes('r9k', 'subsOnly', 'emoteOnly', 'slow', 'ffz_banned'),
}.observes('r9k', 'subsOnly', 'emoteOnly', 'slow', 'ffz_banned', 'followersOnly'),
// User Level
@ -1889,6 +1894,39 @@ FFZ.prototype._modify_room = function(room) {
return f.settings.timeout_notices === 2 || (f.settings.timeout_notices === 1 && this.get('isModeratorOrHigher'));
},
ffzRetokenizeUser: function(user, max_age) {
// Retokenize all messages by a user, or just all messages.
var messages = this.get('messages'),
i = messages.length,
now = new Date;
while(i--) {
var msg = messages[i],
age = msg.date ? (now - msg.date) / 1000 : 0;
if ( max_age && age > max_age )
break;
if ( ! user || msg.from === user ) {
msg.cachedTokens = null;
if ( msg._line )
Ember.propertyDidChange(msg._line, 'ffzTokenizedMessage');
}
}
messages = this.ffzPending;
i = messages ? messages.length : 0;
while(i--) {
var msg = messages[i],
age = msg.date ? (now - msg.date) / 1000 : 0;
if ( max_age && age > max_age )
break;
if ( ! user || msg.from === user )
msg.cachedTokens = null;
}
},
addNotification: function(msg) {
if ( msg ) {
// We don't want to display these notices because we're injecting our own messages.

View file

@ -599,6 +599,13 @@ API.prototype.user_remove_set = function(username, set_id) {
}
API.prototype.retokenize_messages = function(room, user, max_age) {
var rooms = room ? [room] : Object.keys(this.ffz.rooms);
for(var i=0; i < rooms.length; i++)
rooms[i] && rooms[i].room && rooms[i].room.ffzRetokenizeUser(user, max_age);
}
// -----------------------
// Chat Callback
// -----------------------

View file

@ -61,7 +61,7 @@ FFZ.channel_metadata = {};
// Version
var VER = FFZ.version_info = {
major: 3, minor: 5, revision: 400,
major: 3, minor: 5, revision: 405,
toString: function() {
return [VER.major, VER.minor, VER.revision].join(".") + (VER.extra || "");
}

View file

@ -303,7 +303,7 @@ FFZ.prototype.render_metadata = function(key, basic_info, metabar, timers, refre
return false;
e.update_stat = f.render_metadata.bind(f, key, basic_info, metabar, timers, refresh_func, is_hosting);
var data = info.setup ? info.setup.apply(f, basic_info) : basic_info;
var data = info.setup ? info.setup.apply(f, basic_info) : basic_info.copy();
if ( ! (data instanceof Promise) )
data = Promise.resolve(data);
@ -323,7 +323,7 @@ FFZ.prototype.render_metadata = function(key, basic_info, metabar, timers, refre
if ( popup && popup.id === 'ffz-metadata-popup' && popup.dataset.key === key )
return;
var data = info.setup ? info.setup.apply(f, basic_info) : basic_info;
var data = info.setup ? info.setup.apply(f, basic_info) : basic_info.copy();
if ( ! (data instanceof Promise) )
data = Promise.resolve(data);

View file

@ -986,14 +986,14 @@ module.exports = FFZ.utils = {
minutes = Math.floor(seconds / 60);
seconds %= 60;
var out = (weeks ? weeks + (full_names ? ' week' + pluralize(weeks) + ', ' : 'w') : '') +
(days ? days + (full_names ? ' day' + pluralize(days) + ', ' : 'd') : '') +
(hours ? hours + (full_names ? ' hour' + pluralize(hours) + ', ' : 'h') : '') +
(minutes ? minutes + (full_names ? ' minute' + pluralize(minutes) + ', ' : 'm') : '') +
(seconds ? seconds + (full_names ? ' second' + pluralize(seconds) + ', ' : 's') : '');
var out = (weeks ? weeks + (full_names ? ' week' + pluralize(weeks) + ' ' : 'w') : '') +
(days ? days + (full_names ? ' day' + pluralize(days) + ' ' : 'd') : '') +
(hours ? hours + (full_names ? ' hour' + pluralize(hours) + ' ' : 'h') : '') +
(minutes ? minutes + (full_names ? ' minute' + pluralize(minutes) + ' ' : 'm') : '') +
(seconds ? seconds + (full_names ? ' second' + pluralize(seconds) + ' ' : 's') : '');
if ( full_names )
return out.substr(0, out.length - 2);
return out.substr(0, out.length - 1);
DURATIONS[val] = out;
return out;