Commit a6567504 authored by JC Brand's avatar JC Brand

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

updates #555
parent a7184fab
......@@ -87,7 +87,6 @@ converse.plugins.add('converse-bosh', {
_converse.log(
"Could not restore session for jid: "+
jid+" Error message: "+e.message, Strophe.LogLevel.WARN);
_converse.clearSession(); // We want to clear presences (see #555)
return false;
}
}
......
......@@ -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 () {
/* We distinguish between UniView and MultiView instances.
*
......
......@@ -965,7 +965,12 @@ converse.plugins.add('converse-roster', {
}
_converse.presences.browserStorage =
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
* initialized and its cached data fetched.
......
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