Commit 01a88c24 authored by JC Brand's avatar JC Brand

Refetch avatar when occupant's photo hash has changed

parent 6495378a
...@@ -783,12 +783,13 @@ ...@@ -783,12 +783,13 @@
}, },
parsePresence (pres) { parsePresence (pres) {
const id = Strophe.getResourceFromJid(pres.getAttribute("from")); const from = pres.getAttribute("from"),
const data = { data = {
'nick': id, 'from': from,
'type': pres.getAttribute("type"), 'nick': Strophe.getResourceFromJid(from),
'states': [] 'type': pres.getAttribute("type"),
}; 'states': []
};
_.each(pres.childNodes, function (child) { _.each(pres.childNodes, function (child) {
switch (child.nodeName) { switch (child.nodeName) {
case "status": case "status":
...@@ -990,6 +991,20 @@ ...@@ -990,6 +991,20 @@
this.set(_.extend({ this.set(_.extend({
'id': _converse.connection.getUniqueId(), 'id': _converse.connection.getUniqueId(),
}, attributes)); }, 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);
}
} }
}); });
......
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