Updated trimChats slightly.

This commit is contained in:
JC Brand 2016-03-09 09:58:22 +00:00
parent 2dbe2fc5a3
commit 7b2f75ec72

View File

@ -2462,21 +2462,20 @@
* be shown. * be shown.
* *
* It checks whether there is enough space on the page to show * It checks whether there is enough space on the page to show
* another chat box. Otherwise it minimize the oldest chat box * another chat box. Otherwise it minimizes the oldest chat box
* to create space. * to create space.
*/ */
if (converse.no_trimming || (this.model.length <= 1)) { if (converse.no_trimming || (this.model.length <= 1)) {
return; return;
} }
var oldest_chat, var oldest_chat, boxes_width,
$minimized = converse.minimized_chats.$el, $minimized = converse.minimized_chats.$el,
minimized_width = _.contains(this.model.pluck('minimized'), true) ? $minimized.outerWidth(true) : 0, minimized_width = _.contains(this.model.pluck('minimized'), true) ? $minimized.outerWidth(true) : 0,
boxes_width = newchat ? newchat.$el.outerWidth(true) : 0,
new_id = newchat ? newchat.model.get('id') : null; new_id = newchat ? newchat.model.get('id') : null;
boxes_width += _.reduce(this.xget(new_id), function (memo, view) { boxes_width = _.reduce(this.xget(new_id), function (memo, view) {
return memo + this.getChatBoxWidth(view); return memo + this.getChatBoxWidth(view);
}.bind(this), 0); }.bind(this), newchat ? newchat.$el.outerWidth(true) : 0);
if ((minimized_width + boxes_width) > $('body').outerWidth(true)) { if ((minimized_width + boxes_width) > $('body').outerWidth(true)) {
oldest_chat = this.getOldestMaximizedChat([new_id]); oldest_chat = this.getOldestMaximizedChat([new_id]);