Ensure that chats are opened when contacts are clicked.

This commit is contained in:
JC Brand 2017-04-21 19:52:27 +02:00
parent cfd6fad78a
commit b07e6291ea
2 changed files with 4 additions and 9 deletions

View File

@ -690,7 +690,7 @@
openChat: function (ev) { openChat: function (ev) {
if (ev && ev.preventDefault) { ev.preventDefault(); } if (ev && ev.preventDefault) { ev.preventDefault(); }
this.model.save({'num_unread': 0}); this.model.save({'num_unread': 0});
return _converse.chatboxviews.showChat(this.model.attributes); return _converse.chatboxviews.showChat(this.model.attributes, true);
}, },
removeContact: function (ev) { removeContact: function (ev) {

View File

@ -51,19 +51,14 @@
}, },
ChatBoxViews: { ChatBoxViews: {
showChat: function (attrs) { showChat: function (attrs, force) {
/* We only have one chat visible at any one /* We only have one chat visible at any one
* time. So before opening a chat, we make sure all other * time. So before opening a chat, we make sure all other
* chats are hidden. * chats are hidden.
*/ */
var _converse = this.__super__._converse; var _converse = this.__super__._converse;
var chatbox = this.getChatBox(attrs); var chatbox = this.getChatBox(attrs, true);
if (_.isUndefined(chatbox)) { if ((force || !attrs.hidden) && _converse.connection.authenticated) {
// We don't show new chat boxes, but instead open them
// in the background.
attrs.hidden = true;
chatbox = this.getChatBox(attrs, true);
} else if (!attrs.hidden && _converse.connection.authenticated) {
_.each(_converse.chatboxviews.xget(chatbox.get('id')), _.each(_converse.chatboxviews.xget(chatbox.get('id')),
function (view) { function (view) {
if (view.model.get('id') === 'controlbox') { if (view.model.get('id') === 'controlbox') {