|
71 | 71 | this.setBookmarkState(); |
72 | 72 | }, |
73 | 73 |
|
74 | | - renderHeading () { |
| 74 | + renderBookmarkToggle () { |
75 | 75 | const { _converse } = this.__super__, |
76 | 76 | { __ } = _converse; |
| 77 | + const bookmark_button = tpl_chatroom_bookmark_toggle( |
| 78 | + _.assignIn(this.model.toJSON(), { |
| 79 | + info_toggle_bookmark: __('Bookmark this room'), |
| 80 | + bookmarked: this.model.get('bookmarked') |
| 81 | + })); |
| 82 | + const close_button = this.el.querySelector('.close-chatbox-button'); |
| 83 | + close_button.insertAdjacentHTML('afterend', bookmark_button); |
| 84 | + }, |
77 | 85 |
|
| 86 | + renderHeading () { |
| 87 | + this.__super__.renderHeading.apply(this, arguments); |
| 88 | + const { _converse } = this.__super__; |
78 | 89 | if (_converse.allow_bookmarks) { |
79 | 90 | _converse.api.disco.getIdentity('pubsub', 'pep', _converse.bare_jid).then((identity) => { |
80 | 91 | if (_.isNil(identity)) { |
81 | 92 | return; |
82 | 93 | } |
83 | | - const div = document.createElement('div'); |
84 | | - div.innerHTML = this.generateHeadingHTML(); |
85 | | - |
86 | | - const bookmark_button = tpl_chatroom_bookmark_toggle( |
87 | | - _.assignIn( |
88 | | - this.model.toJSON(), |
89 | | - { |
90 | | - info_toggle_bookmark: __('Bookmark this room'), |
91 | | - bookmarked: this.model.get('bookmarked') |
92 | | - } |
93 | | - )); |
94 | | - const close_button = div.querySelector('.close-chatbox-button'); |
95 | | - close_button.insertAdjacentHTML('afterend', bookmark_button); |
96 | | - this.el.querySelector('.chat-head-chatroom').innerHTML = div.innerHTML; |
97 | | - }); |
98 | | - } else { |
99 | | - return this.__super__.renderHeading.apply(this, arguments); |
| 94 | + this.renderBookmarkToggle(); |
| 95 | + }).catch(_.partial(_converse.log, _, Strophe.LogLevel.FATAL)); |
100 | 96 | } |
101 | 97 | }, |
102 | 98 |
|
|
537 | 533 | if (!_converse.allow_bookmarks) { |
538 | 534 | return; |
539 | 535 | } |
540 | | - // Only initialize bookmarks if the server supports PEP |
541 | | - _converse.api.disco.getIdentity('pubsub', 'pep', _converse.bare_jid).then((identity) => { |
542 | | - if (_.isNil(identity)) { |
| 536 | + Promise.all([ |
| 537 | + _converse.api.disco.getIdentity('pubsub', 'pep', _converse.bare_jid), |
| 538 | + _converse.api.disco.supports(Strophe.NS.PUBSUB+'#publish-options', _converse.bare_jid) |
| 539 | + ]).then((args) => { |
| 540 | + const identity = args[0], |
| 541 | + options_support = args[1]; |
| 542 | + |
| 543 | + if (_.isNil(identity) || !options_support.supported) { |
543 | 544 | _converse.emit('bookmarksInitialized'); |
544 | 545 | return; |
545 | 546 | } |
|
0 commit comments