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) {
if (ev && ev.preventDefault) { ev.preventDefault(); }
this.model.save({'num_unread': 0});
return _converse.chatboxviews.showChat(this.model.attributes);
return _converse.chatboxviews.showChat(this.model.attributes, true);
},
removeContact: function (ev) {

View File

@ -51,19 +51,14 @@
},
ChatBoxViews: {
showChat: function (attrs) {
showChat: function (attrs, force) {
/* We only have one chat visible at any one
* time. So before opening a chat, we make sure all other
* chats are hidden.
*/
var _converse = this.__super__._converse;
var chatbox = this.getChatBox(attrs);
if (_.isUndefined(chatbox)) {
// 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) {
var chatbox = this.getChatBox(attrs, true);
if ((force || !attrs.hidden) && _converse.connection.authenticated) {
_.each(_converse.chatboxviews.xget(chatbox.get('id')),
function (view) {
if (view.model.get('id') === 'controlbox') {