Commit f60a0512 authored by JC Brand's avatar JC Brand

Emit an event when the roster is fetched from the cache

We already emit an event when the roster is fetched from the XMPP server,
similarly, it would be useful to know when the roster was instead fetched from
the cache.
parent f9528e71
......@@ -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
~~~~~~~~~~
......
......@@ -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);
}
};
......
......@@ -294,7 +294,9 @@
*/
converse.roster.fetchFromServer(
converse.xmppstatus.sendPresence.bind(converse.xmppstatus));
} else if (converse.send_initial_presence) {
} 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.
......@@ -303,6 +305,7 @@
converse.xmppstatus.sendPresence();
}
}
}
});
}.bind(this)
});
......
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