Fixes #1772. Wait for roster to be fetched

This commit is contained in:
JC Brand 2019-11-03 19:34:55 +01:00
parent 1cba506bc7
commit 93d56898b7
2 changed files with 4 additions and 2 deletions

View File

@ -8,6 +8,7 @@
- #1691: Fix `collection.chatbox is undefined` errors
- #1733: New message notifications for a minimized chat stack on top of each other
- #1757: Chats are hidden behind the controlbox on mobile
- #1772 `_converse.api.contact.add(jid, nick)` fails, says not a function
- Prevent editing of sent file uploads.
- Initial support for sending custom emojis. Currently only between Converse
instances. Still working out a wire protocol for compatibility with other clients.

View File

@ -1075,8 +1075,9 @@ converse.plugins.add('converse-roster', {
* @example
* _converse.api.contacts.add('buddy@example.com', 'Buddy')
*/
'add' (jid, name) {
if (!_.isString(jid) || !_.includes(jid, '@')) {
async add (jid, name) {
await _converse.api.waitUntil('rosterContactsFetched');
if (!_.isString(jid) || !jid.includes('@')) {
throw new TypeError('contacts.add: invalid jid');
}
_converse.roster.addAndSubscribe(jid, _.isEmpty(name)? jid: name);