Skip to content

Commit ccbcf0d

Browse files
committed
Add usersOnline function to pad_userlist, fix a bug where several occurances of current user were pushed to users list.
1 parent aab7186 commit ccbcf0d

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/static/js/pad_userlist.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -508,12 +508,18 @@ var paduserlist = (function()
508508
});
509509
//
510510
},
511-
users: function(){
512-
// Returns an object of users who have been on this pad
513-
// Firstly we have to get live data..
514-
var userList = otherUsersInfo;
511+
usersOnline: function()
512+
{
513+
// Returns an object of users who are currently online on this pad
514+
var userList = [].concat(otherUsersInfo); // Make a copy of the otherUsersInfo, otherwise every call to users modifies the referenced array
515515
// Now we need to add ourselves..
516516
userList.push(myUserInfo);
517+
return userList;
518+
},
519+
users: function(){
520+
// Returns an object of users who have been on this pad
521+
var userList = self.usersOnline();
522+
517523
// Now we add historical authors
518524
var historical = clientVars.collab_client_vars.historicalAuthorData;
519525
for (var key in historical){
@@ -528,7 +534,6 @@ var paduserlist = (function()
528534
if(exists === false){
529535
userList.push(historical[key]);
530536
}
531-
532537
}
533538
return userList;
534539
},

0 commit comments

Comments
 (0)