Commit 1e5b6243 authored by JC Brand's avatar JC Brand

Don't show bookmark toggles when PEP bookmarking not supported by the XMPP server

parent 5e320d03
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
- Avoid `eval` (via `_.template` from lodash). - Avoid `eval` (via `_.template` from lodash).
- Bugfix. Avatars weren't being shown. - Bugfix. Avatars weren't being shown.
- Bugfix. Bookmarks list and open rooms list weren't recreated after logging in for a 2nd time (without reloading the browser). - Bugfix. Bookmarks list and open rooms list weren't recreated after logging in for a 2nd time (without reloading the browser).
- Don't show bookmark toggles when PEP bookmarking not supported by the XMPP server.
- Add LibreJS support - Add LibreJS support
## 3.3.3 (2018-02-14) ## 3.3.3 (2018-02-14)
......
...@@ -87,11 +87,10 @@ ...@@ -87,11 +87,10 @@
this.__super__.renderHeading.apply(this, arguments); this.__super__.renderHeading.apply(this, arguments);
const { _converse } = this.__super__; const { _converse } = this.__super__;
if (_converse.allow_bookmarks) { if (_converse.allow_bookmarks) {
_converse.api.disco.getIdentity('pubsub', 'pep', _converse.bare_jid).then((identity) => { _converse.checkBookmarksSupport().then((supported) => {
if (_.isNil(identity)) { if (supported) {
return;
}
this.renderBookmarkToggle(); this.renderBookmarkToggle();
}
}).catch(_.partial(_converse.log, _, Strophe.LogLevel.FATAL)); }).catch(_.partial(_converse.log, _, Strophe.LogLevel.FATAL));
} }
}, },
...@@ -530,26 +529,31 @@ ...@@ -530,26 +529,31 @@
} }
}); });
const initBookmarks = function () { _converse.checkBookmarksSupport = function () {
if (!_converse.allow_bookmarks) { return new Promise((resolve, reject) => {
return;
}
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) => { ]).then((args) => {
const identity = args[0], resolve(args[0] && (args[1].supported || _converse.allow_public_bookmarks));
options_support = args[1]; });
});
}
if (_.isNil(identity) || (!options_support.supported && !_converse.allow_public_bookmarks)) { const initBookmarks = function () {
_converse.emit('bookmarksInitialized'); if (!_converse.allow_bookmarks) {
return; return;
} }
_converse.checkBookmarksSupport().then((supported) => {
if (supported) {
_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});
_converse.bookmarks.fetchBookmarks() _converse.bookmarks.fetchBookmarks()
.catch(_.partial(_converse.log, _, Strophe.LogLevel.FATAL)) .catch(_.partial(_converse.log, _, Strophe.LogLevel.FATAL))
.then(() => _converse.emit('bookmarksInitialized')); .then(() => _converse.emit('bookmarksInitialized'));
} else {
_converse.emit('bookmarksInitialized');
}
}); });
} }
......
...@@ -118,7 +118,11 @@ ...@@ -118,7 +118,11 @@
toHTML () { toHTML () {
return tpl_rooms_list_item( return tpl_rooms_list_item(
_.extend(this.model.toJSON(), { _.extend(this.model.toJSON(), {
'allow_bookmarks': _converse.allow_bookmarks, // XXX: By the time this renders, the _converse.bookmarks
// collection should already exist if bookmarks are
// supported by the XMPP server. So we can use it
// as a check for support (other ways of checking are async).
'allow_bookmarks': _converse.allow_bookmarks && _converse.bookmarks,
'info_leave_room': __('Leave this room'), 'info_leave_room': __('Leave this room'),
'info_remove_bookmark': __('Unbookmark this room'), 'info_remove_bookmark': __('Unbookmark this room'),
'info_add_bookmark': __('Bookmark this room'), 'info_add_bookmark': __('Bookmark this room'),
......
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