Commit 4eb6df92 authored by JC Brand's avatar JC Brand

Bugfix. Controlbox closed state not remembered

in overlay view mode.

Also refactored a bit to put the method, which determines whether a
chatbox may be shown, on the chatbox itself.
parent 1dd2c4ce
...@@ -48767,10 +48767,6 @@ _converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_3__["default"].plugins ...@@ -48767,10 +48767,6 @@ _converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_3__["default"].plugins
view.close(); view.close();
}); });
return this; return this;
},
chatBoxMayBeShown(chatbox) {
return this.model.chatBoxMayBeShown(chatbox);
} }
}); });
...@@ -50493,10 +50489,6 @@ _converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_5__["default"].plugins ...@@ -50493,10 +50489,6 @@ _converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_5__["default"].plugins
} else { } else {
return this.__super__.model.apply(this, arguments); return this.__super__.model.apply(this, arguments);
} }
},
chatBoxMayBeShown(chatbox) {
return this.__super__.chatBoxMayBeShown.apply(this, arguments) && chatbox.get('id') !== 'controlbox';
} }
}, },
...@@ -50547,6 +50539,10 @@ _converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_5__["default"].plugins ...@@ -50547,6 +50539,10 @@ _converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_5__["default"].plugins
return this.__super__.validate.apply(this, arguments); return this.__super__.validate.apply(this, arguments);
}, },
mayBeShown() {
return this.__super__.mayBeShown.apply(this, arguments) && this.get('id') !== 'controlbox';
},
initialize() { initialize() {
if (this.get('id') === 'controlbox') { if (this.get('id') === 'controlbox') {
this.set({ this.set({
...@@ -52522,6 +52518,10 @@ _converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_1__["default"].plugins ...@@ -52522,6 +52518,10 @@ _converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_1__["default"].plugins
'minimized': true, 'minimized': true,
'time_minimized': moment().format() 'time_minimized': moment().format()
}); });
},
mayBeShown() {
return this.__super__.mayBeShown.apply(this, arguments) && !this.get('minimized');
} }
}, },
...@@ -52697,12 +52697,6 @@ _converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_1__["default"].plugins ...@@ -52697,12 +52697,6 @@ _converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_1__["default"].plugins
return div.innerHTML; return div.innerHTML;
} }
},
ChatBoxes: {
chatBoxMayBeShown(chatbox) {
return this.__super__.chatBoxMayBeShown.apply(this, arguments) && !chatbox.get('minimized');
}
}, },
ChatBoxViews: { ChatBoxViews: {
getChatBoxWidth(view) { getChatBoxWidth(view) {
...@@ -60349,27 +60343,29 @@ _converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_1__["default"].plugins ...@@ -60349,27 +60343,29 @@ _converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_1__["default"].plugins
// relevant objects or classes. // relevant objects or classes.
// //
// new functions which don't exist yet can also be added. // new functions which don't exist yet can also be added.
ChatBoxes: { ChatBox: {
chatBoxMayBeShown(chatbox) { mayBeShown() {
const _converse = this.__super__._converse; const _converse = this.__super__._converse;
if (chatbox.get('id') === 'controlbox') { if (_converse.isUniView()) {
if (this.get('id') === 'controlbox') {
return true; return true;
} }
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) {
return !chatbox.get('hidden'); return !this.get('hidden');
} else { } else {
return true; return true;
} }
} else { } else {
return this.__super__.chatBoxMayBeShown.apply(this, arguments); return this.__super__.mayBeShown.apply(this, arguments);
}
} }
},
},
ChatBoxes: {
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__._converse; const _converse = this.__super__._converse;
...@@ -62615,6 +62611,10 @@ _converse_core__WEBPACK_IMPORTED_MODULE_2__["default"].plugins.add('converse-cha ...@@ -62615,6 +62611,10 @@ _converse_core__WEBPACK_IMPORTED_MODULE_2__["default"].plugins.add('converse-cha
return attrs; return attrs;
}, },
mayBeShown() {
return true;
},
isHidden() { isHidden() {
/* Returns a boolean to indicate whether a newly received /* Returns a boolean to indicate whether a newly received
* message will be visible to the user or not. * message will be visible to the user or not.
...@@ -62687,14 +62687,10 @@ _converse_core__WEBPACK_IMPORTED_MODULE_2__["default"].plugins.add('converse-cha ...@@ -62687,14 +62687,10 @@ _converse_core__WEBPACK_IMPORTED_MODULE_2__["default"].plugins.add('converse-cha
}, null, 'message', 'error'); }, null, 'message', 'error');
}, },
chatBoxMayBeShown(chatbox) {
return true;
},
onChatBoxesFetched(collection) { onChatBoxesFetched(collection) {
/* Show chat boxes upon receiving them from sessionStorage */ /* Show chat boxes upon receiving them from sessionStorage */
collection.each(chatbox => { collection.each(chatbox => {
if (this.chatBoxMayBeShown(chatbox)) { if (chatbox.mayBeShown()) {
chatbox.trigger('show'); chatbox.trigger('show');
} }
}); });
...@@ -62753,6 +62749,8 @@ _converse_core__WEBPACK_IMPORTED_MODULE_2__["default"].plugins.add('converse-cha ...@@ -62753,6 +62749,8 @@ _converse_core__WEBPACK_IMPORTED_MODULE_2__["default"].plugins.add('converse-cha
} else { } else {
// An error message without id likely means that we // An error message without id likely means that we
// sent a message without id (which shouldn't happen). // sent a message without id (which shouldn't happen).
_converse.log('Received an error message without id attribute!', Strophe.LogLevel.ERROR);
_converse.log(message, Strophe.LogLevel.ERROR); _converse.log(message, Strophe.LogLevel.ERROR);
} }
...@@ -145,10 +145,6 @@ converse.plugins.add('converse-chatboxviews', { ...@@ -145,10 +145,6 @@ converse.plugins.add('converse-chatboxviews', {
*/ */
this.each(function (view) { view.close(); }); this.each(function (view) { view.close(); });
return this; return this;
},
chatBoxMayBeShown (chatbox) {
return this.model.chatBoxMayBeShown(chatbox);
} }
}); });
......
...@@ -92,12 +92,7 @@ converse.plugins.add('converse-controlbox', { ...@@ -92,12 +92,7 @@ converse.plugins.add('converse-controlbox', {
} else { } else {
return this.__super__.model.apply(this, arguments); return this.__super__.model.apply(this, arguments);
} }
}, }
chatBoxMayBeShown (chatbox) {
return this.__super__.chatBoxMayBeShown.apply(this, arguments) &&
chatbox.get('id') !== 'controlbox';
},
}, },
ChatBoxViews: { ChatBoxViews: {
...@@ -143,6 +138,11 @@ converse.plugins.add('converse-controlbox', { ...@@ -143,6 +138,11 @@ converse.plugins.add('converse-controlbox', {
return this.__super__.validate.apply(this, arguments); return this.__super__.validate.apply(this, arguments);
}, },
mayBeShown () {
return this.__super__.mayBeShown.apply(this, arguments) &&
this.get('id') !== 'controlbox';
},
initialize () { initialize () {
if (this.get('id') === 'controlbox') { if (this.get('id') === 'controlbox') {
this.set({'time_opened': moment(0).valueOf()}); this.set({'time_opened': moment(0).valueOf()});
......
...@@ -68,6 +68,11 @@ converse.plugins.add('converse-minimize', { ...@@ -68,6 +68,11 @@ converse.plugins.add('converse-minimize', {
'time_minimized': moment().format() 'time_minimized': moment().format()
}); });
}, },
mayBeShown () {
return this.__super__.mayBeShown.apply(this, arguments) &&
!this.get('minimized');
}
}, },
ChatBoxView: { ChatBoxView: {
...@@ -219,13 +224,6 @@ converse.plugins.add('converse-minimize', { ...@@ -219,13 +224,6 @@ converse.plugins.add('converse-minimize', {
} }
}, },
ChatBoxes: {
chatBoxMayBeShown (chatbox) {
return this.__super__.chatBoxMayBeShown.apply(this, arguments) &&
!chatbox.get('minimized');
},
},
ChatBoxViews: { ChatBoxViews: {
getChatBoxWidth (view) { getChatBoxWidth (view) {
if (!view.model.get('minimized') && u.isVisible(view.el)) { if (!view.model.get('minimized') && u.isVisible(view.el)) {
......
...@@ -43,28 +43,30 @@ converse.plugins.add('converse-singleton', { ...@@ -43,28 +43,30 @@ converse.plugins.add('converse-singleton', {
// relevant objects or classes. // relevant objects or classes.
// //
// new functions which don't exist yet can also be added. // new functions which don't exist yet can also be added.
ChatBoxes: {
chatBoxMayBeShown (chatbox) { ChatBox: {
mayBeShown () {
const { _converse } = this.__super__; const { _converse } = this.__super__;
if (chatbox.get('id') === 'controlbox') { if (_converse.isUniView()) {
if (this.get('id') === 'controlbox') {
return true; return true;
} }
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;
if (any_chats_visible) { if (any_chats_visible) {
return !chatbox.get('hidden'); return !this.get('hidden');
} else { } else {
return true; return true;
} }
} else { } else {
return this.__super__.chatBoxMayBeShown.apply(this, arguments); return this.__super__.mayBeShown.apply(this, arguments);
}
} }
}, },
ChatBoxes: {
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__;
......
...@@ -776,6 +776,10 @@ converse.plugins.add('converse-chatboxes', { ...@@ -776,6 +776,10 @@ converse.plugins.add('converse-chatboxes', {
return attrs; return attrs;
}, },
mayBeShown () {
return true;
},
isHidden () { isHidden () {
/* Returns a boolean to indicate whether a newly received /* Returns a boolean to indicate whether a newly received
* message will be visible to the user or not. * message will be visible to the user or not.
...@@ -840,14 +844,10 @@ converse.plugins.add('converse-chatboxes', { ...@@ -840,14 +844,10 @@ converse.plugins.add('converse-chatboxes', {
}, null, 'message', 'error'); }, null, 'message', 'error');
}, },
chatBoxMayBeShown (chatbox) {
return true;
},
onChatBoxesFetched (collection) { onChatBoxesFetched (collection) {
/* Show chat boxes upon receiving them from sessionStorage */ /* Show chat boxes upon receiving them from sessionStorage */
collection.each(chatbox => { collection.each(chatbox => {
if (this.chatBoxMayBeShown(chatbox)) { if (chatbox.mayBeShown()) {
chatbox.trigger('show'); chatbox.trigger('show');
} }
}); });
...@@ -898,6 +898,7 @@ converse.plugins.add('converse-chatboxes', { ...@@ -898,6 +898,7 @@ converse.plugins.add('converse-chatboxes', {
} else { } else {
// An error message without id likely means that we // An error message without id likely means that we
// sent a message without id (which shouldn't happen). // sent a message without id (which shouldn't happen).
_converse.log('Received an error message without id attribute!', Strophe.LogLevel.ERROR);
_converse.log(message, Strophe.LogLevel.ERROR); _converse.log(message, Strophe.LogLevel.ERROR);
} }
const attrs = await chatbox.getMessageAttributesFromStanza(message, message); const attrs = await chatbox.getMessageAttributesFromStanza(message, message);
......
...@@ -41123,6 +41123,10 @@ _converse_core__WEBPACK_IMPORTED_MODULE_2__["default"].plugins.add('converse-cha ...@@ -41123,6 +41123,10 @@ _converse_core__WEBPACK_IMPORTED_MODULE_2__["default"].plugins.add('converse-cha
return attrs; return attrs;
}, },
mayBeShown() {
return true;
},
isHidden() { isHidden() {
/* Returns a boolean to indicate whether a newly received /* Returns a boolean to indicate whether a newly received
* message will be visible to the user or not. * message will be visible to the user or not.
...@@ -41195,14 +41199,10 @@ _converse_core__WEBPACK_IMPORTED_MODULE_2__["default"].plugins.add('converse-cha ...@@ -41195,14 +41199,10 @@ _converse_core__WEBPACK_IMPORTED_MODULE_2__["default"].plugins.add('converse-cha
}, null, 'message', 'error'); }, null, 'message', 'error');
}, },
chatBoxMayBeShown(chatbox) {
return true;
},
onChatBoxesFetched(collection) { onChatBoxesFetched(collection) {
/* Show chat boxes upon receiving them from sessionStorage */ /* Show chat boxes upon receiving them from sessionStorage */
collection.each(chatbox => { collection.each(chatbox => {
if (this.chatBoxMayBeShown(chatbox)) { if (chatbox.mayBeShown()) {
chatbox.trigger('show'); chatbox.trigger('show');
} }
}); });
...@@ -41261,6 +41261,8 @@ _converse_core__WEBPACK_IMPORTED_MODULE_2__["default"].plugins.add('converse-cha ...@@ -41261,6 +41261,8 @@ _converse_core__WEBPACK_IMPORTED_MODULE_2__["default"].plugins.add('converse-cha
} else { } else {
// An error message without id likely means that we // An error message without id likely means that we
// sent a message without id (which shouldn't happen). // sent a message without id (which shouldn't happen).
_converse.log('Received an error message without id attribute!', Strophe.LogLevel.ERROR);
_converse.log(message, Strophe.LogLevel.ERROR); _converse.log(message, Strophe.LogLevel.ERROR);
} }
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