Commit ab4d0204 authored by JC Brand's avatar JC Brand

Update all vcards that might be associated with an occupant

parent d920c2a8
...@@ -985,13 +985,18 @@ ...@@ -985,13 +985,18 @@
}, },
onAvatarChanged () { onAvatarChanged () {
const vcard = _converse.vcards.findWhere({'jid': this.get('from')});
if (!vcard) { return; }
const hash = this.get('image_hash'); const hash = this.get('image_hash');
if (hash && vcard.get('image_hash') !== hash) { const vcards = [];
_converse.api.vcard.update(vcard); 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 () { getDisplayName () {
...@@ -1032,6 +1037,7 @@ ...@@ -1032,6 +1037,7 @@
// Remove absent occupants who've been removed from // Remove absent occupants who've been removed from
// the members lists. // the members lists.
const occupant = this.findOccupant({'jid': removed_jid}); const occupant = this.findOccupant({'jid': removed_jid});
if (!occupant) { return; }
if (occupant.get('show') === 'offline') { if (occupant.get('show') === 'offline') {
occupant.destroy(); occupant.destroy();
} }
......
...@@ -142,7 +142,7 @@ ...@@ -142,7 +142,7 @@
if (_.isString(model)) { if (_.isString(model)) {
return getVCard(_converse, model); return getVCard(_converse, model);
} else if (!model.get('vcard_updated') || force) { } else if (!model.get('vcard_updated') || force) {
const jid = model.get('jid') || model.get('muc_jid'); const jid = model.get('jid');
if (!jid) { if (!jid) {
throw new Error("No JID to get vcard for!"); throw new Error("No JID to get vcard for!");
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment