From a962fc0a24e37f26042ec9841ddfd7c352836208 Mon Sep 17 00:00:00 2001 From: JC Brand Date: Thu, 3 Jan 2019 13:49:33 +0100 Subject: [PATCH] Don't unnecessarily check for #publish-options --- dev.html | 1 - dist/converse.js | 10 ++++++++-- src/converse-bookmarks.js | 12 +++++++----- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/dev.html b/dev.html index 35604bf02..b89024b29 100644 --- a/dev.html +++ b/dev.html @@ -28,7 +28,6 @@ // websocket_url: 'ws://chat.example.org:5280/xmpp-websocket', view_mode: 'fullscreen', archived_messages_page_size: '500', - allow_public_bookmarks: true, notify_all_room_messages: [ 'discuss@conference.conversejs.org' ], diff --git a/dist/converse.js b/dist/converse.js index a85f4985f..3339fb240 100644 --- a/dist/converse.js +++ b/dist/converse.js @@ -49007,8 +49007,14 @@ _converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_0__["default"].plugins }); _converse.checkBookmarksSupport = async function () { - const args = await Promise.all([_converse.api.disco.getIdentity('pubsub', 'pep', _converse.bare_jid), _converse.api.disco.supports(Strophe.NS.PUBSUB + '#publish-options', _converse.bare_jid)]); - return args[0] && (args[1].length || _converse.allow_public_bookmarks); + const identity = await _converse.api.disco.getIdentity('pubsub', 'pep', _converse.bare_jid); + + if (_converse.allow_public_bookmarks) { + return !!identity; + } else { + const supported = await _converse.api.disco.supports(Strophe.NS.PUBSUB + '#publish-options', _converse.bare_jid); + return !!supported.length; + } }; const initBookmarks = async function initBookmarks() { diff --git a/src/converse-bookmarks.js b/src/converse-bookmarks.js index b3f6859fa..b2354666e 100644 --- a/src/converse-bookmarks.js +++ b/src/converse-bookmarks.js @@ -523,11 +523,13 @@ converse.plugins.add('converse-bookmarks', { }); _converse.checkBookmarksSupport = async function () { - const args = await Promise.all([ - _converse.api.disco.getIdentity('pubsub', 'pep', _converse.bare_jid), - _converse.api.disco.supports(Strophe.NS.PUBSUB+'#publish-options', _converse.bare_jid) - ]); - return args[0] && (args[1].length || _converse.allow_public_bookmarks); + const identity = await _converse.api.disco.getIdentity('pubsub', 'pep', _converse.bare_jid); + if (_converse.allow_public_bookmarks) { + return !!identity; + } else { + const supported = await _converse.api.disco.supports(Strophe.NS.PUBSUB+'#publish-options', _converse.bare_jid); + return !!supported.length; + } } const initBookmarks = async function () {