singleton: Ensure obscured chats gets actively hidden.
So that when a room is closed, a previously obscured chat doesn't become visible again. Allowing this would force us to know which chat is visible, so that we can falsify it's `hidden` attribute.
This commit is contained in:
parent
d1bafdb38a
commit
1a95472ebe
@ -24,6 +24,12 @@
|
|||||||
var _ = converse.env._,
|
var _ = converse.env._,
|
||||||
Strophe = converse.env.Strophe;
|
Strophe = converse.env.Strophe;
|
||||||
|
|
||||||
|
function hideChat (view) {
|
||||||
|
if (view.model.get('id') === 'controlbox') { return; }
|
||||||
|
view.model.save({'hidden': true});
|
||||||
|
view.hide();
|
||||||
|
}
|
||||||
|
|
||||||
converse.plugins.add('converse-singleton', {
|
converse.plugins.add('converse-singleton', {
|
||||||
// It's possible however to make optional dependencies non-optional.
|
// It's possible however to make optional dependencies non-optional.
|
||||||
// If the setting "strict_plugin_dependencies" is set to true,
|
// If the setting "strict_plugin_dependencies" is set to true,
|
||||||
@ -39,7 +45,6 @@
|
|||||||
//
|
//
|
||||||
// new functions which don't exist yet can also be added.
|
// new functions which don't exist yet can also be added.
|
||||||
|
|
||||||
|
|
||||||
ChatBoxes: {
|
ChatBoxes: {
|
||||||
createChatBox: function (jid, attrs) {
|
createChatBox: function (jid, attrs) {
|
||||||
/* Make sure new chat boxes are hidden by default.
|
/* Make sure new chat boxes are hidden by default.
|
||||||
@ -59,14 +64,7 @@
|
|||||||
var _converse = this.__super__._converse;
|
var _converse = this.__super__._converse;
|
||||||
var chatbox = this.getChatBox(attrs, true);
|
var chatbox = this.getChatBox(attrs, true);
|
||||||
if ((force || !attrs.hidden) && _converse.connection.authenticated) {
|
if ((force || !attrs.hidden) && _converse.connection.authenticated) {
|
||||||
_.each(_converse.chatboxviews.xget(chatbox.get('id')),
|
_.each(_converse.chatboxviews.xget(chatbox.get('id')), hideChat);
|
||||||
function (view) {
|
|
||||||
if (view.model.get('id') === 'controlbox') {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
view.model.save({'hidden': true});
|
|
||||||
}
|
|
||||||
);
|
|
||||||
chatbox.save({'hidden': false});
|
chatbox.save({'hidden': false});
|
||||||
}
|
}
|
||||||
return this.__super__.showChat.apply(this, arguments);
|
return this.__super__.showChat.apply(this, arguments);
|
||||||
@ -80,13 +78,7 @@
|
|||||||
* chats are hidden.
|
* chats are hidden.
|
||||||
*/
|
*/
|
||||||
if (!this.model.get('hidden')) {
|
if (!this.model.get('hidden')) {
|
||||||
_.each(this.__super__._converse.chatboxviews.xget(this.model.get('id')), function (view) {
|
_.each(this.__super__._converse.chatboxviews.xget(this.model.get('id')), hideChat);
|
||||||
if (view.model.get('id') === 'controlbox') {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
view.hide();
|
|
||||||
view.model.set({'hidden': true});
|
|
||||||
});
|
|
||||||
return this.__super__._show.apply(this, arguments);
|
return this.__super__._show.apply(this, arguments);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -98,8 +90,7 @@
|
|||||||
* 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.
|
||||||
*/
|
*/
|
||||||
_.each(this.__super__._converse.chatboxviews.xget('controlbox'),
|
_.each(this.__super__._converse.chatboxviews.xget('controlbox'), hideChat);
|
||||||
function (view) { view.model.save({'hidden': true}); });
|
|
||||||
this.model.save({'hidden': false});
|
this.model.save({'hidden': false});
|
||||||
return this.__super__.openChat.apply(this, arguments);
|
return this.__super__.openChat.apply(this, arguments);
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user