Commit d4d03925 authored by JC Brand's avatar JC Brand

Set `hidden` to `true` by default for chats in singleton mode.

However, when a new chat is created due to an incoming message, and
there aren't any other chats visible, then show it.
parent 37b62225
...@@ -62326,13 +62326,16 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_ ...@@ -62326,13 +62326,16 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
comparator: 'time' comparator: 'time'
}); });
_converse.ChatBox = _converse.ModelWithVCardAndPresence.extend({ _converse.ChatBox = _converse.ModelWithVCardAndPresence.extend({
defaults: { defaults() {
return {
'bookmarked': false, 'bookmarked': false,
'chat_state': undefined, 'chat_state': undefined,
'num_unread': 0, 'num_unread': 0,
'type': 'chatbox', 'type': 'chatbox',
'message_type': 'chat', 'message_type': 'chat',
'url': '' 'url': '',
'hidden': _.includes(['mobile', 'fullscreen'], _converse.view_mode)
};
}, },
initialize() { initialize() {
...@@ -76610,8 +76613,20 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_ ...@@ -76610,8 +76613,20 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
// new functions which don't exist yet can also be added. // new functions which don't exist yet can also be added.
ChatBoxes: { ChatBoxes: {
chatBoxMayBeShown(chatbox) { chatBoxMayBeShown(chatbox) {
if (_.includes(['mobile', 'fullscreen', 'embedded'], this.__super__._converse.view_mode)) { const _converse = this.__super__._converse;
if (chatbox.get('id') === 'controlbox') {
return true;
}
if (_.includes(['mobile', 'fullscreen', 'embedded'], _converse.view_mode)) {
const any_chats_visible = _converse.chatboxes.filter(cb => cb.get('id') != 'controlbox').filter(cb => !cb.get('hidden')).length > 0;
if (any_chats_visible) {
return !chatbox.get('hidden'); return !chatbox.get('hidden');
} else {
return true;
}
} else { } else {
return this.__super__.chatBoxMayBeShown.apply(this, arguments); return this.__super__.chatBoxMayBeShown.apply(this, arguments);
} }
...@@ -245,13 +245,16 @@ ...@@ -245,13 +245,16 @@
_converse.ChatBox = _converse.ModelWithVCardAndPresence.extend({ _converse.ChatBox = _converse.ModelWithVCardAndPresence.extend({
defaults: { defaults () {
return {
'bookmarked': false, 'bookmarked': false,
'chat_state': undefined, 'chat_state': undefined,
'num_unread': 0, 'num_unread': 0,
'type': 'chatbox', 'type': 'chatbox',
'message_type': 'chat', 'message_type': 'chat',
'url': '' 'url': '',
'hidden': _.includes(['mobile', 'fullscreen'], _converse.view_mode)
}
}, },
initialize () { initialize () {
......
...@@ -46,8 +46,20 @@ ...@@ -46,8 +46,20 @@
ChatBoxes: { ChatBoxes: {
chatBoxMayBeShown (chatbox) { chatBoxMayBeShown (chatbox) {
if (_.includes(['mobile', 'fullscreen', 'embedded'], this.__super__._converse.view_mode)) { const { _converse } = this.__super__;
if (chatbox.get('id') === 'controlbox') {
return true;
}
if (_.includes(['mobile', 'fullscreen', 'embedded'], _converse.view_mode)) {
const any_chats_visible = _converse.chatboxes
.filter((cb) => cb.get('id') != 'controlbox')
.filter((cb) => !cb.get('hidden')).length > 0;
if (any_chats_visible) {
return !chatbox.get('hidden'); return !chatbox.get('hidden');
} else {
return true;
}
} else { } else {
return this.__super__.chatBoxMayBeShown.apply(this, arguments); return this.__super__.chatBoxMayBeShown.apply(this, arguments);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment