From ab4d0204f3d3f713a48000d8c40c66b1b51ad27c Mon Sep 17 00:00:00 2001 From: JC Brand Date: Fri, 25 May 2018 15:55:34 +0200 Subject: [PATCH] Update all vcards that might be associated with an occupant --- src/converse-muc.js | 16 +++++++++++----- src/converse-vcard.js | 2 +- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/converse-muc.js b/src/converse-muc.js index afd2939bb..d8b6f72be 100644 --- a/src/converse-muc.js +++ b/src/converse-muc.js @@ -985,13 +985,18 @@ }, onAvatarChanged () { - const vcard = _converse.vcards.findWhere({'jid': this.get('from')}); - if (!vcard) { return; } - const hash = this.get('image_hash'); - if (hash && vcard.get('image_hash') !== hash) { - _converse.api.vcard.update(vcard); + const vcards = []; + if (this.get('jid')) { + vcards.push(this.updateVCard(_converse.vcards.findWhere({'jid': this.get('jid')}))); } + vcards.push(this.updateVCard(_converse.vcards.findWhere({'jid': this.get('from')}))); + + _.forEach(_.filter(vcards, undefined), (vcard) => { + if (hash && vcard.get('image_hash') !== hash) { + _converse.api.vcard.update(vcard); + } + }); }, getDisplayName () { @@ -1032,6 +1037,7 @@ // Remove absent occupants who've been removed from // the members lists. const occupant = this.findOccupant({'jid': removed_jid}); + if (!occupant) { return; } if (occupant.get('show') === 'offline') { occupant.destroy(); } diff --git a/src/converse-vcard.js b/src/converse-vcard.js index d45e517ab..e1d15961e 100644 --- a/src/converse-vcard.js +++ b/src/converse-vcard.js @@ -142,7 +142,7 @@ if (_.isString(model)) { return getVCard(_converse, model); } else if (!model.get('vcard_updated') || force) { - const jid = model.get('jid') || model.get('muc_jid'); + const jid = model.get('jid'); if (!jid) { throw new Error("No JID to get vcard for!"); }