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

3.5.327. component:chat/chat-room-manager cometh.

This commit is contained in:
SirStendec 2016-10-12 20:54:09 -04:00
parent 6ab4bd64a8
commit 4e2c2f5056
7 changed files with 62 additions and 49 deletions

View file

@ -1,3 +1,16 @@
<div class="list-header">3.5.327 <time datetime="2016-10-12">(2016-10-12)</time></div>
<ul class="chat-menu-content menu-side-padding">
<li>Fixed: More changes to work with the new chat room manager component. Now with less breaking!</li>
</ul>
<div class="list-header">3.5.326 <time datetime="2016-10-12">(2016-10-12)</time></div>
<ul class="chat-menu-content menu-side-padding">
<li>Fixed: Twitch changed chat to use a component rather than a view, breaking FFZ's handling of it.</li>
<li>Fixed: Maybe a fix an issue parsing IDs on Safari for one user? Don't know.</li>
<li>&nbsp;</li>
<li>Significant code changes in 30 minutes or it's free.</li>
</ul>
<div class="list-header">3.5.325 <time datetime="2016-10-12">(2016-10-12)</time></div> <div class="list-header">3.5.325 <time datetime="2016-10-12">(2016-10-12)</time></div>
<ul class="chat-menu-content menu-side-padding"> <ul class="chat-menu-content menu-side-padding">
<li>Added: Tab-complete commands in chat.</li> <li>Added: Tab-complete commands in chat.</li>

View file

@ -75,8 +75,8 @@ FFZ.settings_info.minimal_chat = {
},0); },0);
} }
if ( (val === 1 || val === 3) && this._chatv && this._chatv.get('controller.showList') ) if ( (val === 1 || val === 3) && this._chatv && this._chatv.get('isShowingList') )
this._chatv.set('controller.showList', false); this._chatv.set('isShowingList', false);
// Remove the style if we have it. // Remove the style if we have it.
if ( ! (val > 1) && this._chat_style ) { if ( ! (val > 1) && this._chat_style ) {
@ -459,8 +459,8 @@ FFZ.prototype.setup_chatview = function() {
} }
this.log("Hooking the Ember Chat view."); this.log("Hooking the Ember Chat Room Manager component.");
this.update_views('view:chat', this.modify_chat_view); this.update_views('component:chat/chat-room-manager', this.modify_chat_room_manager);
this.log("Hooking the Ember from-display-preview component."); this.log("Hooking the Ember from-display-preview component.");
this.update_views('component:chat/from-display-preview', this.modify_from_display_preview); this.update_views('component:chat/from-display-preview', this.modify_from_display_preview);
@ -542,13 +542,16 @@ FFZ.prototype.modify_from_display_preview = function(view) {
// Modify Chat View // Modify Chat View
// -------------------- // --------------------
FFZ.prototype.modify_chat_view = function(view) { FFZ.prototype.modify_chat_room_manager = function(component) {
var f = this; var f = this,
utils.ember_reopen_view(view, { controller = utils.ember_lookup('controller:chat');
utils.ember_reopen_view(component, {
ffz_init: function() { ffz_init: function() {
f._chatv = this; f._chatv = this;
var room_id = this.get('controller.currentRoom.id'), var t = this,
room_id = this.get('room.name'),
el = this.get('element'); el = this.get('element');
el && el.setAttribute('data-room', room_id || ""); el && el.setAttribute('data-room', room_id || "");
@ -565,11 +568,10 @@ FFZ.prototype.modify_chat_view = function(view) {
this.ffz_pruner = setInterval(this.ffzPruneTabs.bind(this), 10000); this.ffz_pruner = setInterval(this.ffzPruneTabs.bind(this), 10000);
setTimeout(function() { setTimeout(function() {
if ( f.settings.group_tabs && f._chatv && f._chatv._ffz_tabs ) if ( f.settings.group_tabs && t._ffz_tabs )
f._chatv.$('.chat-room').css('top', f._chatv._ffz_tabs.offsetHeight + "px"); t.$('.chat-room').css('top', t._ffz_tabs.offsetHeight + "px");
var controller = f._chatv && f._chatv.get('controller'); t.set('isShowingList', false);
controller && controller.set('showList', false);
}, 1000); }, 1000);
}, },
@ -616,7 +618,7 @@ FFZ.prototype.modify_chat_view = function(view) {
}, },
ffzChangeRoom: Ember.observer('controller.currentRoom', function() { ffzChangeRoom: Ember.observer('room', function() {
f.update_ui_link(); f.update_ui_link();
this.ffz_unread = this.ffz_unread || {}; this.ffz_unread = this.ffz_unread || {};
@ -624,14 +626,14 @@ FFZ.prototype.modify_chat_view = function(view) {
if ( f._mod_card ) if ( f._mod_card )
f._mod_card.get('closeAction')(); f._mod_card.get('closeAction')();
var room = this.get('controller.currentRoom'), var room = controller.get('currentRoom'),
room_id = room && room.get('id'), room_id = room && room.get('id'),
el = this.get('element'), el = this.get('element'),
was_unread = room_id && this.ffz_unread[room_id], was_unread = room_id && this.ffz_unread[room_id],
update_height = false; update_height = false;
if ( room ) { if ( room ) {
room.resetUnreadCount(); room.resetUnreadCount && room.resetUnreadCount();
room.ffz_last_view = Date.now(); room.ffz_last_view = Date.now();
} }
@ -666,7 +668,7 @@ FFZ.prototype.modify_chat_view = function(view) {
if ( this._ffz_invite ) if ( this._ffz_invite )
this._ffz_invite.classList.toggle('hidden', ! can_invite); this._ffz_invite.classList.toggle('hidden', ! can_invite);
this.set('controller.showInviteUser', can_invite && this.get('controller.showInviteUser')); this.set('isShowingInviteUser', false);
update_height = true; update_height = true;
} }
@ -697,8 +699,8 @@ FFZ.prototype.modify_chat_view = function(view) {
return; return;
if ( f.settings.pinned_rooms.indexOf(this._ffz_host) === -1 ) { if ( f.settings.pinned_rooms.indexOf(this._ffz_host) === -1 ) {
if ( this.get('controller.currentRoom') === this._ffz_host_room ) if ( controller.get('currentRoom') === this._ffz_host_room )
this.get('controller').blurRoom(); controller.blurRoom();
// Schedule the room to be destroyed. This is after a short // Schedule the room to be destroyed. This is after a short
// delay to make sure we aren't just loading the room in a // delay to make sure we aren't just loading the room in a
@ -746,7 +748,6 @@ FFZ.prototype.modify_chat_view = function(view) {
ffzUpdateMenuUnread: function() { ffzUpdateMenuUnread: function() {
var el = this.get('element'), var el = this.get('element'),
controller = this.get('controller'),
unread_display = el && el.querySelector('#ffz-group-tabs .button .notifications'); unread_display = el && el.querySelector('#ffz-group-tabs .button .notifications');
Ember.propertyDidChange(controller, 'notificationsCount'); Ember.propertyDidChange(controller, 'notificationsCount');
@ -757,7 +758,7 @@ FFZ.prototype.modify_chat_view = function(view) {
ffzUpdateUnread: function(target_id) { ffzUpdateUnread: function(target_id) {
var current_id = this.get('controller.currentRoom.id'); var current_id = this.get('room.id');
this.ffz_unread = this.ffz_unread || {}; this.ffz_unread = this.ffz_unread || {};
if ( target_id === current_id ) if ( target_id === current_id )
@ -889,7 +890,7 @@ FFZ.prototype.modify_chat_view = function(view) {
// Current Channel // Current Channel
var room = this.get('controller.currentChannelRoom'), var room = controller.get('currentChannelRoom'),
room_id = room && room.get('id'), room_id = room && room.get('id'),
row; row;
@ -932,7 +933,7 @@ FFZ.prototype.modify_chat_view = function(view) {
} else } else
group_table.innerHTML = ''; group_table.innerHTML = '';
_.each(this.get('controller.connectedPrivateGroupRooms'), function(room) { _.each(controller.get('connectedPrivateGroupRooms'), function(room) {
var row = view.ffzBuildRow(room); var row = view.ffzBuildRow(room);
row && group_table && group_table.appendChild(row); row && group_table && group_table.appendChild(row);
}); });
@ -957,11 +958,11 @@ FFZ.prototype.modify_chat_view = function(view) {
room_id = room.get('id'), room_id = room.get('id'),
group = room.get('isGroupRoom'), group = room.get('isGroupRoom'),
active_channel = room === this.get('controller.currentRoom'), active_channel = room === controller.get('currentRoom'),
unread = utils.format_unread(active_channel ? 0 : room.get('unreadCount')), unread = utils.format_unread(active_channel ? 0 : room.get('unreadCount')),
name = room.get('channel.display_name') || room.get('tmiRoom.displayName') || (group ? room.get('tmiRoom.name') : FFZ.get_capitalization(room_id, function(name) { name = room.get('channel.display_name') || room.get('tmiRoom.displayName') || (group ? room.get('tmiRoom.name') : FFZ.get_capitalization(room_id, function(name) {
var active_channel = room === view.get('controller.currentRoom'); var active_channel = room === controller.get('currentRoom');
unread = utils.format_unread(active_channel ? 0 : room.get('unreadCount')); unread = utils.format_unread(active_channel ? 0 : room.get('unreadCount'));
var results = group ? [name, undefined] : f.format_display_name(name, room_id, true); var results = group ? [name, undefined] : f.format_display_name(name, room_id, true);
name_el.innerHTML = results[0] + ' <span>' + unread + '</span>'; name_el.innerHTML = results[0] + ' <span>' + unread + '</span>';
@ -1039,12 +1040,10 @@ FFZ.prototype.modify_chat_view = function(view) {
row.appendChild(toggle_pinned); row.appendChild(toggle_pinned);
row.addEventListener('click', function() { row.addEventListener('click', function() {
var controller = view.get('controller');
controller.focusRoom(room); controller.focusRoom(room);
controller.set('showList', false); view.set('isShowingList', false);
}); });
room._ffz_row = row; room._ffz_row = row;
return row; return row;
}, },
@ -1105,8 +1104,7 @@ FFZ.prototype.modify_chat_view = function(view) {
jQuery(link).tipsy({gravity: "n", offset: 10}); jQuery(link).tipsy({gravity: "n", offset: 10});
link.addEventListener('click', function() { link.addEventListener('click', function() {
var controller = view.get('controller'); view.set('isShowingList', !view.get('isShowingList'));
controller && controller.set('showList', !controller.get('showList'));
}); });
tabs.appendChild(link); tabs.appendChild(link);
@ -1118,17 +1116,16 @@ FFZ.prototype.modify_chat_view = function(view) {
link.innerHTML = '<figure class="icon">' + constants.INVITE + '</figure>'; link.innerHTML = '<figure class="icon">' + constants.INVITE + '</figure>';
link.addEventListener('click', function() { link.addEventListener('click', function() {
var controller = view.get('controller'); view.set('isShowingInviteUser', view.get('room.canInvite') && !view.get('isShowingInviteUser') );
controller && controller.set('showInviteUser', controller.get('currentRoom.canInvite') && !controller.get('showInviteUser'));
}); });
link.classList.toggle('hidden', !this.get("controller.currentRoom.canInvite")); link.classList.toggle('hidden', !this.get('room.canInvite'));
view._ffz_invite = link; view._ffz_invite = link;
tabs.appendChild(link); tabs.appendChild(link);
// Current Room // Current Room
var room = this.get('controller.currentChannelRoom'), var room = controller.get('currentChannelRoom'),
room_id = room && room.get('id'), room_id = room && room.get('id'),
tab; tab;
@ -1156,7 +1153,7 @@ FFZ.prototype.modify_chat_view = function(view) {
// Group Chat // Group Chat
_.each(this.get('controller.connectedPrivateGroupRooms'), function(room) { _.each(controller.get('connectedPrivateGroupRooms'), function(room) {
var tab = view.ffzBuildTab(room); var tab = view.ffzBuildTab(room);
tab && tabs.appendChild(tab); tab && tabs.appendChild(tab);
}); });
@ -1173,7 +1170,7 @@ FFZ.prototype.modify_chat_view = function(view) {
tab = document.createElement('span'), name, unread, icon = '', tab = document.createElement('span'), name, unread, icon = '',
room_id = room.get('id'), room_id = room.get('id'),
group = room.get('isGroupRoom'), group = room.get('isGroupRoom'),
active_channel = room === this.get('controller.currentRoom'); active_channel = room === controller.get('currentRoom');
tab.setAttribute('data-room', room_id); tab.setAttribute('data-room', room_id);
@ -1188,7 +1185,7 @@ FFZ.prototype.modify_chat_view = function(view) {
unread = utils.format_unread(active_channel ? 0 : room.get('unreadCount')); unread = utils.format_unread(active_channel ? 0 : room.get('unreadCount'));
name = room.get('channel.display_name') || room.get('tmiRoom.displayName') || (group ? room.get('tmiRoom.name') : FFZ.get_capitalization(room_id, function(name) { name = room.get('channel.display_name') || room.get('tmiRoom.displayName') || (group ? room.get('tmiRoom.name') : FFZ.get_capitalization(room_id, function(name) {
var active_channel = room === view.get('controller.currentRoom'); var active_channel = room === controller.get('currentRoom');
unread = utils.format_unread(active_channel ? 0 : room.get('unreadCount')); unread = utils.format_unread(active_channel ? 0 : room.get('unreadCount'));
var results = group ? [name, undefined] : f.format_display_name(name, room_id, true, true); var results = group ? [name, undefined] : f.format_display_name(name, room_id, true, true);
tab.innerHTML = icon + results[0] + '<span>' + unread + '</span>'; tab.innerHTML = icon + results[0] + '<span>' + unread + '</span>';
@ -1213,10 +1210,9 @@ FFZ.prototype.modify_chat_view = function(view) {
tab.title += '<br>' + results[1]; tab.title += '<br>' + results[1];
tab.addEventListener('click', function() { tab.addEventListener('click', function() {
var controller = view.get('controller');
controller.focusRoom(room); controller.focusRoom(room);
controller.set('showList', false); view.set('isShowingList', false);
}); });
room._ffz_tab = tab; room._ffz_tab = tab;
return tab; return tab;
@ -1224,8 +1220,8 @@ FFZ.prototype.modify_chat_view = function(view) {
ffzTabVisible: function(room_id) { ffzTabVisible: function(room_id) {
var room = f.rooms[room_id] && f.rooms[room_id].room, var room = f.rooms[room_id] && f.rooms[room_id].room,
is_current = room === this.get('controller.currentRoom'), is_current = room === controller.get('currentRoom'),
is_channel = room === this.get('controller.currentChannelRoom'), is_channel = room === controller.get('currentChannelRoom'),
now = Date.now(); now = Date.now();

View file

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

View file

@ -66,13 +66,13 @@ var FFZ = window.FrankerFaceZ,
FFZ.SRC_IDS = {}, FFZ.SRC_IDS = {},
FFZ.src_to_id = function(src) { FFZ.src_to_id = function(src) {
if ( FFZ.SRC_IDS.hasOwnProperty(src) ) if ( Object.hasOwnProperty.call(FFZ.SRC_IDS, src) )
return FFZ.SRC_IDS[src]; return FFZ.SRC_IDS[src];
var match = /\/emoticons\/v1\/(\d+)\/1\.0/.exec(src), var match = /\/emoticons\/v1\/(\d+)\/1\.0/.exec(src),
id = match ? parseInt(match[1]) : null; id = match ? parseInt(match[1]) : null;
if ( Number.isNaN(id) ) if ( typeof id === "number" && (isNaN(id) || !isFinite(id)) )
id = null; id = null;
FFZ.SRC_IDS[src] = id; FFZ.SRC_IDS[src] = id;

View file

@ -344,7 +344,7 @@ FFZ.menu_pages.about = {
about: { about: {
name: "About", name: "About",
render: function(view, container, inner, menu) { render: function(view, container, inner, menu) {
var room = this.rooms[view.get("context.currentRoom.id")], var room = this.rooms[view.get('room.id')],
has_emotes = false, f = this; has_emotes = false, f = this;
if ( room && room.set ) { if ( room && room.set ) {

View file

@ -447,7 +447,8 @@ FFZ.prototype._ui_change_page = function(view, inner, menu, container, page) {
FFZ.menu_pages.channel = { FFZ.menu_pages.channel = {
render: function(view, inner) { render: function(view, inner) {
// Get the current room. // Get the current room.
var room_id = view.get('controller.currentRoom.id'), var controller = utils.ember_lookup('controller:chat'),
room_id = controller.get('currentRoom.id'),
room = this.rooms[room_id], room = this.rooms[room_id],
has_product = false, has_product = false,
f = this; f = this;
@ -778,7 +779,8 @@ FFZ.prototype._add_emote = function(view, emote, favorites_set, favorites_key, e
text = input_el.value; text = input_el.value;
} else { } else {
room = view.get('controller.currentRoom'); var controller = utils.ember_lookup('controller:chat');
room = controller.get('currentRoom');
text = room.get('messageToSend') || ''; text = room.get('messageToSend') || '';
} }

View file

@ -97,7 +97,8 @@ FFZ.menu_pages.myemotes = {
has_sets: function(view) { has_sets: function(view) {
var user = this.get_user(), var user = this.get_user(),
tmi = view && view.get('controller.currentRoom.tmiSession'), controller = utils.ember_lookup('controller:chat'),
tmi = controller && controller.get('currentRoom.tmiSession'),
ffz_sets = user && this.users[user.login] && this.users[user.login].sets || [], ffz_sets = user && this.users[user.login] && this.users[user.login].sets || [],
twitch_sets = (tmi && tmi.getEmotes() || {'emoticon_sets': {}})['emoticon_sets'], twitch_sets = (tmi && tmi.getEmotes() || {'emoticon_sets': {}})['emoticon_sets'],
@ -180,7 +181,8 @@ FFZ.menu_pages.myemotes = {
}, },
render_lists: function(view, container, favorites_only) { render_lists: function(view, container, favorites_only) {
var tmi = view.get('controller.currentRoom.tmiSession'), var controller = utils.ember_lookup('controller:chat'),
tmi = controller && controller.get('currentRoom.tmiSession'),
twitch_sets = (tmi && tmi.getEmotes() || {'emoticon_sets': {}})['emoticon_sets'], twitch_sets = (tmi && tmi.getEmotes() || {'emoticon_sets': {}})['emoticon_sets'],
user = this.get_user(), user = this.get_user(),