mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-21 07:56:16 -04:00
Add userColor
query param to set initial color
Add a URL parameter which sets the initial color for a user, e.g.: http://example.com/p/mypad?userColor=%2300ff00 Sanitize the given color value to ensure that it's a valid css value (could be any supported CSS color format -- #fff, rgba(), "red", etc). Shortly after rejoining a pad, the server responds with a USER_NEWINFO message which may contain an old color value; however, this message arrives after we have set and sent the new color value to the server. To avoid this race condition, if the query parameter has been set, ignore the color value in a USER_NEWINFO message which matches our user ID.
This commit is contained in:
parent
6f37de2fae
commit
afc90604bf
2 changed files with 33 additions and 0 deletions
|
@ -358,6 +358,14 @@ function getCollabClient(ace2editor, serverVars, initialUserInfo, options, _pad)
|
|||
{
|
||||
var userInfo = msg.userInfo;
|
||||
var id = userInfo.userId;
|
||||
|
||||
// Avoid a race condition when setting colors. If our color was set by a
|
||||
// query param, ignore our own "new user" message's color value.
|
||||
if (id === initialUserInfo.userId && initialUserInfo.globalUserColor)
|
||||
{
|
||||
msg.userInfo.colorId = initialUserInfo.globalUserColor;
|
||||
}
|
||||
|
||||
|
||||
if (userSet[id])
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue