converse-roster: dedupe group names

This commit is contained in:
JC Brand 2021-06-23 11:14:02 +02:00
parent 629f382642
commit 522998bade
2 changed files with 2 additions and 2 deletions

View File

@ -12,6 +12,7 @@ const { Strophe, $iq, $pres } = converse.env;
const RosterContact = Model.extend({
defaults: {
'chat_state': undefined,
'groups': [],
'image': _converse.DEFAULT_IMAGE,
'image_type': _converse.DEFAULT_IMAGE_TYPE,
'num_unread': 0,
@ -25,7 +26,6 @@ const RosterContact = Model.extend({
const bare_jid = Strophe.getBareJidFromJid(jid).toLowerCase();
attributes.jid = bare_jid;
this.set(Object.assign({
'groups': [],
'id': bare_jid,
'jid': bare_jid,
'user_id': Strophe.getNodeFromJid(jid)

View File

@ -299,7 +299,7 @@ const RosterContacts = Collection.extend({
const contact = this.get(jid);
const subscription = item.getAttribute("subscription");
const ask = item.getAttribute("ask");
const groups = Array.from(item.getElementsByTagName('group')).map(e => e.textContent);
const groups = [...new Set(sizzle('group', item).map(e => e.textContent))];
if (!contact) {
if ((subscription === "none" && ask === null) || (subscription === "remove")) {
return; // We're lazy when adding contacts.