Add usersOnline function to pad_userlist, fix a bug where several occurances of current user were pushed to users list.

This commit is contained in:
Mikk Andresen 2016-01-05 18:22:32 +02:00
parent aab7186486
commit ccbcf0ddce
1 changed files with 10 additions and 5 deletions

View File

@ -508,12 +508,18 @@ var paduserlist = (function()
}); });
// //
}, },
users: function(){ usersOnline: function()
// Returns an object of users who have been on this pad {
// Firstly we have to get live data.. // Returns an object of users who are currently online on this pad
var userList = otherUsersInfo; var userList = [].concat(otherUsersInfo); // Make a copy of the otherUsersInfo, otherwise every call to users modifies the referenced array
// Now we need to add ourselves.. // Now we need to add ourselves..
userList.push(myUserInfo); userList.push(myUserInfo);
return userList;
},
users: function(){
// Returns an object of users who have been on this pad
var userList = self.usersOnline();
// Now we add historical authors // Now we add historical authors
var historical = clientVars.collab_client_vars.historicalAuthorData; var historical = clientVars.collab_client_vars.historicalAuthorData;
for (var key in historical){ for (var key in historical){
@ -528,7 +534,6 @@ var paduserlist = (function()
if(exists === false){ if(exists === false){
userList.push(historical[key]); userList.push(historical[key]);
} }
} }
return userList; return userList;
}, },