diff --git a/docs/source/development.rst b/docs/source/development.rst index 9a8a715e6..cbd272919 100644 --- a/docs/source/development.rst +++ b/docs/source/development.rst @@ -798,6 +798,15 @@ Event Types Here are the different events that are emitted: +cachedRoster +~~~~~~~~~~~~ + +The contacts roster has been retrieved from the local cache (`sessionStorage`). + +``converse.listen.on('cachedRoster', function (event, items) { ... });`` + +See also the `roster` event further down. + callButtonClicked ~~~~~~~~~~~~~~~~~ @@ -937,10 +946,13 @@ After the user has sent out a direct invitation, to a roster contact, asking the roster ~~~~~~ -When the roster is updated. +When the roster has been received from the XMPP server. ``converse.listen.on('roster', function (event, items) { ... });`` +See also the `cachedRoster` event further up, which gets called instead of +`roster` if its already in `sessionStorage`. + rosterPush ~~~~~~~~~~ diff --git a/src/converse-core.js b/src/converse-core.js index d6866b9d6..deb241261 100755 --- a/src/converse-core.js +++ b/src/converse-core.js @@ -358,6 +358,8 @@ } if (converse.auto_changed_status === true) { converse.auto_changed_status = false; + // XXX: we should really remember the original state here, and + // then set it back to that... converse.xmppstatus.setStatus(converse.default_state); } }; diff --git a/src/converse-rosterview.js b/src/converse-rosterview.js index b4a30252d..d19d60725 100644 --- a/src/converse-rosterview.js +++ b/src/converse-rosterview.js @@ -294,13 +294,16 @@ */ converse.roster.fetchFromServer( converse.xmppstatus.sendPresence.bind(converse.xmppstatus)); - } else if (converse.send_initial_presence) { - /* We're not going to fetch the roster again because we have - * it already cached in sessionStorage, but we still need to - * send out a presence stanza because this is a new session. - * See: https://github.com/jcbrand/converse.js/issues/536 - */ - converse.xmppstatus.sendPresence(); + } else { + converse.emit('cachedRoster', collection); + if (converse.send_initial_presence) { + /* We're not going to fetch the roster again because we have + * it already cached in sessionStorage, but we still need to + * send out a presence stanza because this is a new session. + * See: https://github.com/jcbrand/converse.js/issues/536 + */ + converse.xmppstatus.sendPresence(); + } } } });