mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-02-01 03:12:42 +01:00
Merge pull request #2871 from tiblu/pad_userlist_add_usersOnline_fix_bug_in_users
pad_userlist.js: BUGFIX: users() returning duplicates on several calls. FEATURE: usersOnline() returns only online users
This commit is contained in:
commit
dbc777dd13
2 changed files with 20 additions and 9 deletions
|
@ -1,5 +1,5 @@
|
||||||
/**
|
/**
|
||||||
* This code is mostly from the old Etherpad. Please help us to comment this code.
|
* This code is mostly from the old Etherpad. Please help us to comment this code.
|
||||||
* This helps other people to understand this code better and helps them to improve it.
|
* This helps other people to understand this code better and helps them to improve it.
|
||||||
* TL;DR COMMENTS ON THIS FILE ARE HIGHLY APPRECIATED
|
* TL;DR COMMENTS ON THIS FILE ARE HIGHLY APPRECIATED
|
||||||
*/
|
*/
|
||||||
|
@ -351,7 +351,7 @@ function getCollabClient(ace2editor, serverVars, initialUserInfo, options, _pad)
|
||||||
msg.userInfo.colorId = initialUserInfo.globalUserColor;
|
msg.userInfo.colorId = initialUserInfo.globalUserColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (userSet[id])
|
if (userSet[id])
|
||||||
{
|
{
|
||||||
userSet[id] = userInfo;
|
userSet[id] = userInfo;
|
||||||
|
@ -405,7 +405,7 @@ function getCollabClient(ace2editor, serverVars, initialUserInfo, options, _pad)
|
||||||
$("#chatloadmessagesball").css("display", "none");
|
$("#chatloadmessagesball").css("display", "none");
|
||||||
|
|
||||||
// there are less than 100 messages or we reached the top
|
// there are less than 100 messages or we reached the top
|
||||||
if(chat.historyPointer <= 0)
|
if(chat.historyPointer <= 0)
|
||||||
$("#chatloadmessagesbutton").css("display", "none");
|
$("#chatloadmessagesbutton").css("display", "none");
|
||||||
else // there are still more messages, re-show the load-button
|
else // there are still more messages, re-show the load-button
|
||||||
$("#chatloadmessagesbutton").css("display", "block");
|
$("#chatloadmessagesbutton").css("display", "block");
|
||||||
|
@ -414,6 +414,12 @@ function getCollabClient(ace2editor, serverVars, initialUserInfo, options, _pad)
|
||||||
{
|
{
|
||||||
callbacks.onServerMessage(msg.payload);
|
callbacks.onServerMessage(msg.payload);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//HACKISH: User messages do not have "payload" but "userInfo", so that all "handleClientMessage_USER_" hooks would work, populate payload
|
||||||
|
//FIXME: USER_* messages to have "payload" property instead of "userInfo", seems like a quite a big work
|
||||||
|
if(msg.type.indexOf("USER_") > -1) {
|
||||||
|
msg.payload = msg.userInfo;
|
||||||
|
}
|
||||||
hooks.callAll('handleClientMessage_' + msg.type, {payload: msg.payload});
|
hooks.callAll('handleClientMessage_' + msg.type, {payload: msg.payload});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -441,7 +447,7 @@ function getCollabClient(ace2editor, serverVars, initialUserInfo, options, _pad)
|
||||||
{
|
{
|
||||||
colorId = clientVars.colorPalette[colorId];
|
colorId = clientVars.colorPalette[colorId];
|
||||||
}
|
}
|
||||||
|
|
||||||
var cssColor = colorId;
|
var cssColor = colorId;
|
||||||
if (inactive)
|
if (inactive)
|
||||||
{
|
{
|
||||||
|
|
|
@ -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;
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue