I noticed the beta 3 fix a bug of Roster:
var newItems = ext.getAllItems();
for( var i=0; i < newItems.length; i++ ) {
//var item = newItems+;
var item = newItems;
//if a user is in several groups, add it as item for each group. Fix by guido
for (var j=0; j < item.getGroups().length;j++) {
addRosterItem( item.jid, item.name, RosterExtension.SHOW_UNAVAILABLE, “Offline”, item.getGroups()[j], item.subscription.toLowerCase() );
}
}
it is used to fix the bug of user in several groups. but how about a user out of any group? I don’'t know how the JEP specify the standard behavior, but I do think we should handle it. the beta 2 can handle it:
var newItems = ext.getAllItems();
for( var i=0; i < newItems.length; i++ ) {
var item = newItems+;
addRosterItem( item.jid, item.name, RosterExtension.SHOW_UNAVAILABLE, “Offline”, item.getGroups()[0], item.subscription.toLowerCase() );
}
finally I came to a solution of this case:
var newItems = ext.getAllItems();
for( var i=0; i < newItems.length; i++ ) {
var item = newItems+;
if (item.getGroups().length == 0) {
//if a user is in no group, add it without group specified. Fix by taowen
addRosterItem( item.jid, item.name, RosterExtension.SHOW_UNAVAILABLE, “Offline”, null, item.subscription.toLowerCase() );
} else {
//if a user is in several groups, add it as item for each group. Fix by guido
for (var j=0; j < item.getGroups().length;j++) {
addRosterItem( item.jid, item.name, RosterExtension.SHOW_UNAVAILABLE, “Offline”, item.getGroups()[j], item.subscription.toLowerCase() );
}
}
}