Commit e3bce029 authored by JC Brand's avatar JC Brand

More usage of async/await

parent 55fce912
...@@ -517,15 +517,12 @@ converse.plugins.add('converse-bookmarks', { ...@@ -517,15 +517,12 @@ converse.plugins.add('converse-bookmarks', {
} }
}); });
_converse.checkBookmarksSupport = function () { _converse.checkBookmarksSupport = async function () {
return new Promise((resolve, reject) => { const args = await Promise.all([
Promise.all([
_converse.api.disco.getIdentity('pubsub', 'pep', _converse.bare_jid), _converse.api.disco.getIdentity('pubsub', 'pep', _converse.bare_jid),
_converse.api.disco.supports(Strophe.NS.PUBSUB+'#publish-options', _converse.bare_jid) _converse.api.disco.supports(Strophe.NS.PUBSUB+'#publish-options', _converse.bare_jid)
]).then((args) => { ]);
resolve(args[0] && (args[1].length || _converse.allow_public_bookmarks)); return args[0] && (args[1].length || _converse.allow_public_bookmarks);
}).catch(_.partial(_converse.log, _, Strophe.LogLevel.FATAL));
}).catch(_.partial(_converse.log, _, Strophe.LogLevel.FATAL));
} }
const initBookmarks = async function () { const initBookmarks = async function () {
...@@ -537,10 +534,8 @@ converse.plugins.add('converse-bookmarks', { ...@@ -537,10 +534,8 @@ converse.plugins.add('converse-bookmarks', {
_converse.bookmarks = new _converse.Bookmarks(); _converse.bookmarks = new _converse.Bookmarks();
_converse.bookmarksview = new _converse.BookmarksView({'model': _converse.bookmarks}); _converse.bookmarksview = new _converse.BookmarksView({'model': _converse.bookmarks});
await _converse.bookmarks.fetchBookmarks(); await _converse.bookmarks.fetchBookmarks();
_converse.emit('bookmarksInitialized');
} else {
_converse.emit('bookmarksInitialized');
} }
_converse.emit('bookmarksInitialized');
} }
u.onMultipleEvents([ u.onMultipleEvents([
......
...@@ -408,8 +408,8 @@ converse.plugins.add('converse-chatview', { ...@@ -408,8 +408,8 @@ converse.plugins.add('converse-chatview', {
if (_.isEmpty(resources)) { if (_.isEmpty(resources)) {
return; return;
} }
const results = await Promise.all(_.map(_.keys(resources), (resource) => const results = await Promise.all(_.map(_.keys(resources),
_converse.api.disco.supports(Strophe.NS.SPOILER, `${contact_jid}/${resource}`) resource => _converse.api.disco.supports(Strophe.NS.SPOILER, `${contact_jid}/${resource}`)
)); ));
if (_.filter(results, 'length').length) { if (_.filter(results, 'length').length) {
const html = tpl_spoiler_button(this.model.toJSON()); const html = tpl_spoiler_button(this.model.toJSON());
......
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