Save hidden state of singletons if possible

This commit is contained in:
JC Brand 2018-09-06 09:44:44 +02:00
parent 0a5a3b5d07
commit 4903d748d0
2 changed files with 14 additions and 6 deletions

11
dist/converse.js vendored
View File

@ -76740,13 +76740,14 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
const _converse$env = converse.env,
_ = _converse$env._,
Strophe = _converse$env.Strophe;
const u = converse.env.utils;
function hideChat(view) {
if (view.model.get('id') === 'controlbox') {
return;
}
view.model.save({
u.safeSave(view.model, {
'hidden': true
});
view.hide();
@ -76820,7 +76821,9 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
if (_converse.isSingleton()) {
_.each(this.__super__._converse.chatboxviews.xget(this.model.get('id')), hideChat);
this.model.set('hidden', false);
u.safeSave(this.model, {
'hidden': false
});
}
return this.__super__._show.apply(this, arguments);
@ -76834,7 +76837,9 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
if (_converse.isSingleton()) {
_.each(this.__super__._converse.chatboxviews.xget(this.model.get('id')), hideChat);
this.model.set('hidden', false);
u.safeSave(this.model, {
'hidden': false
});
}
return this.__super__.show.apply(this, arguments);

View File

@ -22,13 +22,16 @@
}(this, function (converse) {
"use strict";
const { _, Strophe } = converse.env;
const u = converse.env.utils;
function hideChat (view) {
if (view.model.get('id') === 'controlbox') { return; }
view.model.save({'hidden': true});
u.safeSave(view.model, {'hidden': true});
view.hide();
}
converse.plugins.add('converse-singleton', {
// It's possible however to make optional dependencies non-optional.
// If the setting "strict_plugin_dependencies" is set to true,
@ -94,7 +97,7 @@
const { _converse } = this.__super__;
if (_converse.isSingleton()) {
_.each(this.__super__._converse.chatboxviews.xget(this.model.get('id')), hideChat);
this.model.set('hidden', false);
u.safeSave(this.model, {'hidden': false});
}
return this.__super__._show.apply(this, arguments);
}
@ -105,7 +108,7 @@
const { _converse } = this.__super__;
if (_converse.isSingleton()) {
_.each(this.__super__._converse.chatboxviews.xget(this.model.get('id')), hideChat);
this.model.set('hidden', false);
u.safeSave(this.model, {'hidden': false});
}
return this.__super__.show.apply(this, arguments);
}