Skip to content

Commit eae3a77

Browse files
committed
Fixup
1 parent 56748fc commit eae3a77

File tree

4 files changed

+31
-4
lines changed

4 files changed

+31
-4
lines changed

src/headless/plugins/bookmarks/collection.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ class Bookmarks extends Collection {
244244
async setBookmarksFromStanza(stanza) {
245245
const bookmarks = await parseStanzaForBookmarks(stanza);
246246
bookmarks.forEach(
247-
/** @param {import('./types.js').BookmarkAttrs} attrs */
247+
/** @param {import('./types.ts').BookmarkAttrs} attrs */
248248
(attrs) => {
249249
const bookmark = this.get(attrs.jid);
250250
bookmark ? bookmark.save(attrs) : this.create(attrs);

src/headless/plugins/pubsub/api.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ export default {
281281
*/
282282
async subscriptions(jid, node) {
283283
const service = jid || (await api.disco.entities.find(Strophe.NS.PUBSUB));
284-
const own_jid = _converse.session.get('jid');
284+
const own_jid = _converse.session.get('bare_jid');
285285
const iq = stx`
286286
<iq xmlns="jabber:client"
287287
type="get"
@@ -291,7 +291,15 @@ export default {
291291
<subscriptions${node ? ` node="${node}"` : ''}/>
292292
</pubsub>
293293
</iq>`;
294-
const response = await api.sendIQ(iq);
294+
295+
let response;
296+
try {
297+
response = await api.sendIQ(iq);
298+
} catch (e) {
299+
log.warn(e);
300+
return [];
301+
}
302+
295303
const subs_el = response.querySelector('pubsub subscriptions');
296304
if (!subs_el) return [];
297305

src/headless/plugins/pubsub/index.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,11 @@
66
import _converse from '../../shared/_converse.js';
77
import converse from '../../shared/api/public.js';
88
import pubsub_api from './api.js';
9+
import { default as PubSubNode } from './node.js';
10+
import { default as PubSubNodes } from './nodes.js';
911
import '../disco/index.js';
1012

13+
1114
const { Strophe, sizzle } = converse.env;
1215

1316
Strophe.addNamespace('PUBSUB_ERROR', Strophe.NS.PUBSUB + '#errors');
@@ -18,6 +21,18 @@ converse.plugins.add('converse-pubsub', {
1821
initialize() {
1922
const { api } = _converse;
2023
Object.assign(_converse.api, pubsub_api);
24+
Object.assign(_converse.exports, { PubSubNodes });
25+
26+
api.listen.on('connected', () => {
27+
const pubsub_nodes = new _converse.exports.PubSubNodes();
28+
Object.assign(_converse.state, { pubsub_nodes });
29+
/**
30+
* @event _converse#pubSubNodesInitialized
31+
* @example _converse.api.listen.on('pubSubInitialized', () => { ... });
32+
* @example _converse.api.waitUntil('pubSubInitialized').then(() => { ... });
33+
*/
34+
api.trigger('pubSubNodesInitialized');
35+
});
2136

2237
api.listen.on(
2338
'parseErrorStanza',
@@ -38,3 +53,5 @@ converse.plugins.add('converse-pubsub', {
3853
);
3954
},
4055
});
56+
57+
export { PubSubNode, PubSubNodes };
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1-
export {};
1+
import { default as PubSubNode } from './node.js';
2+
import { default as PubSubNodes } from './nodes.js';
3+
export { PubSubNode, PubSubNodes };
24
//# sourceMappingURL=index.d.ts.map

0 commit comments

Comments
 (0)