Refetch avatar when occupant's photo hash has changed

This commit is contained in:
JC Brand 2018-05-03 14:50:27 +02:00
parent 6495378a19
commit 01a88c24a8

View File

@ -783,9 +783,10 @@
},
parsePresence (pres) {
const id = Strophe.getResourceFromJid(pres.getAttribute("from"));
const data = {
'nick': id,
const from = pres.getAttribute("from"),
data = {
'from': from,
'nick': Strophe.getResourceFromJid(from),
'type': pres.getAttribute("type"),
'states': []
};
@ -990,6 +991,20 @@
this.set(_.extend({
'id': _converse.connection.getUniqueId(),
}, attributes));
this.on('change:image_hash', this.onAvatarChanged, this);
},
onAvatarChanged () {
this.avatar = _converse.avatars.findWhere({
'muc_jid': this.get('from')
});
if (!this.avatar) { return; }
const hash = this.get('image_hash');
if (hash && this.avatar.get('image_hash') !== hash) {
_converse.api.vcard.update(this.avatar);
}
}
});