Only fetch presences when we're resuming an existing session.

updates #555
This commit is contained in:
JC Brand 2019-06-05 11:31:34 +02:00
parent a7184fab41
commit a656750459
3 changed files with 16 additions and 2 deletions

View File

@ -87,7 +87,6 @@ converse.plugins.add('converse-bosh', {
_converse.log( _converse.log(
"Could not restore session for jid: "+ "Could not restore session for jid: "+
jid+" Error message: "+e.message, Strophe.LogLevel.WARN); jid+" Error message: "+e.message, Strophe.LogLevel.WARN);
_converse.clearSession(); // We want to clear presences (see #555)
return false; return false;
} }
} }

View File

@ -323,6 +323,16 @@ function isTestEnv () {
} }
_converse.haveResumed = function () {
if (_converse.api.connection.isType('bosh')) {
return _converse.connfeedback.get('connection_status') === Strophe.Status.ATTACHED;
} else {
// XXX: Not binding means that the session was resumed.
// This seems very fragile. Perhaps a better way is possible.
return !_converse.connection.do_bind;
}
}
_converse.isUniView = function () { _converse.isUniView = function () {
/* We distinguish between UniView and MultiView instances. /* We distinguish between UniView and MultiView instances.
* *

View File

@ -965,7 +965,12 @@ converse.plugins.add('converse-roster', {
} }
_converse.presences.browserStorage = _converse.presences.browserStorage =
new BrowserStorage.session(`converse.presences-${_converse.bare_jid}`); new BrowserStorage.session(`converse.presences-${_converse.bare_jid}`);
_converse.presences.fetch();
if (_converse.haveResumed()) {
_converse.presences.fetch();
} else {
_converse.presences.browserStorage._clear();
}
/** /**
* Triggered once the _converse.Presences collection has been * Triggered once the _converse.Presences collection has been
* initialized and its cached data fetched. * initialized and its cached data fetched.