New bug introduced by fixing a bug of Roster

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() );

}

}

}

Hi taowen, I see you found the same bug that I have:

http://www.jivesoftware.org/forums/thread.jspa?threadID=14922&tstart=0

I think your code is missing something:

your line :

var item = newItems;

shouldn’'t it read

var item = newItems[ i ];

I now see that this forums eats the (without the spaces) and turns it into italic.

So never mind what I just posted.