Hello,
i’m trying to implement a chat on my website with ReactJS, Strophe and Openfire.
This is what I want to achieve:
As you can see it’s a list of contacts (the roster entries) with their pictures.
Here’s how i’m doing it currently
//get contacts from roster
connection.roster.init(connection);
connection.roster.get(function (roster) {
let payload = [];
for (var i in roster) {
payload.push({ id: roster[i].jid, name: roster[i].name, status: 'offline' });
}
store.dispatch(add(payload));
// !!!! we need this only for the image
for (var j in payload) {
connection.vcard.get((vcard) => {
let vCardObject = getVcardInformationObject(vcard, false);
if (vCardObject) {
store.dispatch(updateRosterEntry(vCardObject));
}
}, payload[j].id);
}
});
As you can see I load the roster and then for each roster entry I fetch the vcard information because the vcard information contains the PHOTO along with a lof of other information. I think this might be a performance problem when you have a lot of roster entries.
Is there a way that Openfire returns the photo information in the initial request? So that I wouldn’t call getVcardInformation
on every roster entry?