Cache vCard retrieval.

We still need a cache invalidation mechanism. Currently PEP event notifications look most promising.
http://xmpp.org/extensions/xep-0163.html
http://xmpp.org/extensions/xep-0292.html#self-pubsub
This commit is contained in:
JC Brand 2013-03-20 11:34:54 +02:00
parent 219089d261
commit e9916ec912

View File

@ -701,7 +701,6 @@
$target.parent().remove();
$('form.search-xmpp-contact').hide();
}
});
xmppchat.RoomsPanel = Backbone.View.extend({
@ -1363,15 +1362,28 @@
});
xmppchat.getVCard = function (jid, callback) {
// TODO: cache vcards
xmppchat.connection.vcard.get($.proxy(function (iq) {
$vcard = $(iq).find('vCard');
var fullname = $vcard.find('FN').text(),
img = $vcard.find('BINVAL').text(),
img_type = $vcard.find('TYPE').text(),
url = $vcard.find('URL').text();
callback(jid, fullname, img, img_type, url);
}, this), jid)
/* First we check if we don't already have a RosterItem, since it will
* contain all the vCard details.
*/
var model = xmppchat.roster.getItem(jid);
if (model) {
callback(
model.get('jid'),
model.get('fullname'),
model.get('image'),
model.get('image_type'),
model.get('url')
)
} else {
xmppchat.connection.vcard.get($.proxy(function (iq) {
$vcard = $(iq).find('vCard');
var fullname = $vcard.find('FN').text(),
img = $vcard.find('BINVAL').text(),
img_type = $vcard.find('TYPE').text(),
url = $vcard.find('URL').text();
callback(jid, fullname, img, img_type, url);
}, this), jid)
}
}
xmppchat.RosterItems = Backbone.Collection.extend({