Commit 93d56898 authored by JC Brand's avatar JC Brand

Fixes #1772. Wait for roster to be fetched

parent 1cba506b
......@@ -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.
......
......@@ -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);
......
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