Skip to content

Commit d2e96ee

Browse files
committed
fix remove bookmark
1 parent b8c5137 commit d2e96ee

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

CHANGES.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## 12.0.1 (Unreleased)
4+
5+
- #3822: Bookmark removal not working
6+
37
## 12.0.0 (2025-08-28)
48

59
- #3581: Don't unnecessarily regenerate pot and po files

src/headless/plugins/bookmarks/collection.js

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ class Bookmarks extends Collection {
3838
this.on(
3939
'remove',
4040
/** @param {Bookmark} bookmark */
41-
(_, bookmark) => this.sendBookmarkStanza(bookmark),
41+
(bookmark, _) =>
42+
this.removeBookmark(bookmark)
43+
.catch((e) => log.fatal(e)),
4244
this
4345
);
4446

@@ -182,6 +184,28 @@ class Bookmarks extends Collection {
182184
});
183185
}
184186

187+
/**
188+
* @param {Bookmark} bookmark
189+
* @returns {Promise<void|Element>}
190+
*/
191+
async removeBookmark(bookmark) {
192+
const bare_jid = _converse.session.get('bare_jid');
193+
const node = (await api.disco.supports(`${Strophe.NS.BOOKMARKS2}#compat`, bare_jid))
194+
? Strophe.NS.BOOKMARKS2
195+
: Strophe.NS.BOOKMARKS;
196+
const stanza = stx`
197+
<iq xmlns="jabber:client"
198+
from="${bare_jid}"
199+
type="set">
200+
<pubsub xmlns="${Strophe.NS.PUBSUB}">
201+
<retract node="${node}">
202+
<item id="${bookmark.get('jid')}"/>
203+
</retract>
204+
</pubsub>
205+
</iq>`;
206+
await api.sendIQ(stanza);
207+
}
208+
185209
/**
186210
* @param {Element} iq
187211
*/

0 commit comments

Comments
 (0)