Rename isSingleton to isUniView

We distinguish between UniView and MultiView instances.

UniView means that only one chat is visible, even though there might be multiple ongoing chats.
MultiView means that multiple chats may be visible simultaneously.
This commit is contained in:
JC Brand 2018-12-04 12:14:52 +01:00
parent dda0af6404
commit 118bc20478
7 changed files with 31 additions and 21 deletions

25
dist/converse.js vendored
View File

@ -55729,7 +55729,7 @@ _converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_0__["default"].plugins
}; };
_converse.isMessageToHiddenChat = function (message) { _converse.isMessageToHiddenChat = function (message) {
if (_.includes(['mobile', 'fullscreen', 'embedded'], _converse.view_mode)) { if (_converse.isUniView()) {
const jid = Strophe.getBareJidFromJid(message.getAttribute('from')), const jid = Strophe.getBareJidFromJid(message.getAttribute('from')),
view = _converse.chatboxviews.get(jid); view = _converse.chatboxviews.get(jid);
@ -58624,7 +58624,7 @@ _converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_0__["default"].plugins
// supported by the XMPP server. So we can use it // supported by the XMPP server. So we can use it
// as a check for support (other ways of checking are async). // as a check for support (other ways of checking are async).
'allow_bookmarks': _converse.allow_bookmarks && _converse.bookmarks, 'allow_bookmarks': _converse.allow_bookmarks && _converse.bookmarks,
'currently_open': _converse.isSingleton() && !this.model.get('hidden'), 'currently_open': _converse.isUniView() && !this.model.get('hidden'),
'info_leave_room': __('Leave this groupchat'), 'info_leave_room': __('Leave this groupchat'),
'info_remove_bookmark': __('Unbookmark this groupchat'), 'info_remove_bookmark': __('Unbookmark this groupchat'),
'info_add_bookmark': __('Bookmark this groupchat'), 'info_add_bookmark': __('Bookmark this groupchat'),
@ -59291,7 +59291,7 @@ _converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_5__["default"].plugins
this.el.setAttribute('data-status', show); this.el.setAttribute('data-status', show);
this.highlight(); this.highlight();
if (_converse.isSingleton()) { if (_converse.isUniView()) {
const chatbox = _converse.chatboxes.get(this.model.get('jid')); const chatbox = _converse.chatboxes.get(this.model.get('jid'));
if (chatbox) { if (chatbox) {
@ -59344,7 +59344,7 @@ _converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_5__["default"].plugins
highlight() { highlight() {
/* If appropriate, highlight the contact (by adding the 'open' class). /* If appropriate, highlight the contact (by adding the 'open' class).
*/ */
if (_converse.isSingleton()) { if (_converse.isUniView()) {
const chatbox = _converse.chatboxes.get(this.model.get('jid')); const chatbox = _converse.chatboxes.get(this.model.get('jid'));
if (chatbox) { if (chatbox) {
@ -60043,7 +60043,7 @@ _converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_1__["default"].plugins
return true; return true;
} }
if (_converse.isSingleton()) { if (_converse.isUniView()) {
const any_chats_visible = _converse.chatboxes.filter(cb => cb.get('id') != 'controlbox').filter(cb => !cb.get('hidden')).length > 0; const any_chats_visible = _converse.chatboxes.filter(cb => cb.get('id') != 'controlbox').filter(cb => !cb.get('hidden')).length > 0;
if (any_chats_visible) { if (any_chats_visible) {
@ -60060,7 +60060,7 @@ _converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_1__["default"].plugins
/* Make sure new chat boxes are hidden by default. */ /* Make sure new chat boxes are hidden by default. */
const _converse = this.__super__._converse; const _converse = this.__super__._converse;
if (_converse.isSingleton()) { if (_converse.isUniView()) {
attrs = attrs || {}; attrs = attrs || {};
attrs.hidden = true; attrs.hidden = true;
} }
@ -60073,7 +60073,7 @@ _converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_1__["default"].plugins
shouldShowOnTextMessage() { shouldShowOnTextMessage() {
const _converse = this.__super__._converse; const _converse = this.__super__._converse;
if (_converse.isSingleton()) { if (_converse.isUniView()) {
return false; return false;
} else { } else {
return this.__super__.shouldShowOnTextMessage.apply(this, arguments); return this.__super__.shouldShowOnTextMessage.apply(this, arguments);
@ -60087,7 +60087,7 @@ _converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_1__["default"].plugins
*/ */
const _converse = this.__super__._converse; const _converse = this.__super__._converse;
if (_converse.isSingleton()) { if (_converse.isUniView()) {
_.each(this.__super__._converse.chatboxviews.xget(this.model.get('id')), hideChat); _.each(this.__super__._converse.chatboxviews.xget(this.model.get('id')), hideChat);
u.safeSave(this.model, { u.safeSave(this.model, {
@ -60103,7 +60103,7 @@ _converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_1__["default"].plugins
show(focus) { show(focus) {
const _converse = this.__super__._converse; const _converse = this.__super__._converse;
if (_converse.isSingleton()) { if (_converse.isUniView()) {
_.each(this.__super__._converse.chatboxviews.xget(this.model.get('id')), hideChat); _.each(this.__super__._converse.chatboxviews.xget(this.model.get('id')), hideChat);
u.safeSave(this.model, { u.safeSave(this.model, {
@ -62796,7 +62796,12 @@ _converse.emit = function (name) {
} }
}; };
_converse.isSingleton = function () { _converse.isUniView = function () {
/* We distinguish between UniView and MultiView instances.
*
* UniView means that only one chat is visible, even though there might be multiple ongoing chats.
* MultiView means that multiple chats may be visible simultaneously.
*/
return _lodash_noconflict__WEBPACK_IMPORTED_MODULE_4___default.a.includes(['mobile', 'fullscreen', 'embedded'], _converse.view_mode); return _lodash_noconflict__WEBPACK_IMPORTED_MODULE_4___default.a.includes(['mobile', 'fullscreen', 'embedded'], _converse.view_mode);
}; };

View File

@ -60,7 +60,7 @@
// have to mock stanza traffic. // have to mock stanza traffic.
}, async function (done, _converse) { }, async function (done, _converse) {
spyOn(_converse, 'isSingleton').and.callFake(() => true); spyOn(_converse, 'isUniView').and.callFake(() => true);
let room_els, item; let room_els, item;
test_utils.openControlBox(); test_utils.openControlBox();

View File

@ -74,7 +74,7 @@ converse.plugins.add('converse-notification', {
}; };
_converse.isMessageToHiddenChat = function (message) { _converse.isMessageToHiddenChat = function (message) {
if (_.includes(['mobile', 'fullscreen', 'embedded'], _converse.view_mode)) { if (_converse.isUniView()) {
const jid = Strophe.getBareJidFromJid(message.getAttribute('from')), const jid = Strophe.getBareJidFromJid(message.getAttribute('from')),
view = _converse.chatboxviews.get(jid); view = _converse.chatboxviews.get(jid);

View File

@ -116,7 +116,7 @@ converse.plugins.add('converse-roomslist', {
// supported by the XMPP server. So we can use it // supported by the XMPP server. So we can use it
// as a check for support (other ways of checking are async). // as a check for support (other ways of checking are async).
'allow_bookmarks': _converse.allow_bookmarks && _converse.bookmarks, 'allow_bookmarks': _converse.allow_bookmarks && _converse.bookmarks,
'currently_open': _converse.isSingleton() && !this.model.get('hidden'), 'currently_open': _converse.isUniView() && !this.model.get('hidden'),
'info_leave_room': __('Leave this groupchat'), 'info_leave_room': __('Leave this groupchat'),
'info_remove_bookmark': __('Unbookmark this groupchat'), 'info_remove_bookmark': __('Unbookmark this groupchat'),
'info_add_bookmark': __('Bookmark this groupchat'), 'info_add_bookmark': __('Bookmark this groupchat'),

View File

@ -392,7 +392,7 @@ converse.plugins.add('converse-rosterview', {
this.el.setAttribute('data-status', show); this.el.setAttribute('data-status', show);
this.highlight(); this.highlight();
if (_converse.isSingleton()) { if (_converse.isUniView()) {
const chatbox = _converse.chatboxes.get(this.model.get('jid')); const chatbox = _converse.chatboxes.get(this.model.get('jid'));
if (chatbox) { if (chatbox) {
if (chatbox.get('hidden')) { if (chatbox.get('hidden')) {
@ -447,7 +447,7 @@ converse.plugins.add('converse-rosterview', {
highlight () { highlight () {
/* If appropriate, highlight the contact (by adding the 'open' class). /* If appropriate, highlight the contact (by adding the 'open' class).
*/ */
if (_converse.isSingleton()) { if (_converse.isUniView()) {
const chatbox = _converse.chatboxes.get(this.model.get('jid')); const chatbox = _converse.chatboxes.get(this.model.get('jid'));
if (chatbox) { if (chatbox) {
if (chatbox.get('hidden')) { if (chatbox.get('hidden')) {

View File

@ -50,7 +50,7 @@ converse.plugins.add('converse-singleton', {
if (chatbox.get('id') === 'controlbox') { if (chatbox.get('id') === 'controlbox') {
return true; return true;
} }
if (_converse.isSingleton()) { if (_converse.isUniView()) {
const any_chats_visible = _converse.chatboxes const any_chats_visible = _converse.chatboxes
.filter(cb => cb.get('id') != 'controlbox') .filter(cb => cb.get('id') != 'controlbox')
.filter(cb => !cb.get('hidden')).length > 0; .filter(cb => !cb.get('hidden')).length > 0;
@ -68,7 +68,7 @@ converse.plugins.add('converse-singleton', {
createChatBox (jid, attrs) { createChatBox (jid, attrs) {
/* Make sure new chat boxes are hidden by default. */ /* Make sure new chat boxes are hidden by default. */
const { _converse } = this.__super__; const { _converse } = this.__super__;
if (_converse.isSingleton()) { if (_converse.isUniView()) {
attrs = attrs || {}; attrs = attrs || {};
attrs.hidden = true; attrs.hidden = true;
} }
@ -79,7 +79,7 @@ converse.plugins.add('converse-singleton', {
ChatBoxView: { ChatBoxView: {
shouldShowOnTextMessage () { shouldShowOnTextMessage () {
const { _converse } = this.__super__; const { _converse } = this.__super__;
if (_converse.isSingleton()) { if (_converse.isUniView()) {
return false; return false;
} else { } else {
return this.__super__.shouldShowOnTextMessage.apply(this, arguments); return this.__super__.shouldShowOnTextMessage.apply(this, arguments);
@ -92,7 +92,7 @@ converse.plugins.add('converse-singleton', {
* chats are hidden. * chats are hidden.
*/ */
const { _converse } = this.__super__; const { _converse } = this.__super__;
if (_converse.isSingleton()) { if (_converse.isUniView()) {
_.each(this.__super__._converse.chatboxviews.xget(this.model.get('id')), hideChat); _.each(this.__super__._converse.chatboxviews.xget(this.model.get('id')), hideChat);
u.safeSave(this.model, {'hidden': false}); u.safeSave(this.model, {'hidden': false});
} }
@ -103,7 +103,7 @@ converse.plugins.add('converse-singleton', {
ChatRoomView: { ChatRoomView: {
show (focus) { show (focus) {
const { _converse } = this.__super__; const { _converse } = this.__super__;
if (_converse.isSingleton()) { if (_converse.isUniView()) {
_.each(this.__super__._converse.chatboxviews.xget(this.model.get('id')), hideChat); _.each(this.__super__._converse.chatboxviews.xget(this.model.get('id')), hideChat);
u.safeSave(this.model, {'hidden': false}); u.safeSave(this.model, {'hidden': false});
} }

View File

@ -312,7 +312,12 @@ _converse.emit = function (name) {
} }
}; };
_converse.isSingleton = function () { _converse.isUniView = function () {
/* We distinguish between UniView and MultiView instances.
*
* UniView means that only one chat is visible, even though there might be multiple ongoing chats.
* MultiView means that multiple chats may be visible simultaneously.
*/
return _.includes(['mobile', 'fullscreen', 'embedded'], _converse.view_mode); return _.includes(['mobile', 'fullscreen', 'embedded'], _converse.view_mode);
} }