mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-20 23:46:14 -04:00
PadMessageHandler: Use await
instead of p.then()
This commit is contained in:
parent
3262ff1cb9
commit
8756fed80d
1 changed files with 33 additions and 35 deletions
|
@ -1193,48 +1193,46 @@ async function handleClientReady(client, message)
|
||||||
let cached = historicalAuthorData[author];
|
let cached = historicalAuthorData[author];
|
||||||
|
|
||||||
// reuse previously created cache of author's data
|
// reuse previously created cache of author's data
|
||||||
let p = cached ? Promise.resolve(cached) : authorManager.getAuthor(author);
|
const authorInfo = await (cached ? Promise.resolve(cached) : authorManager.getAuthor(author));
|
||||||
|
|
||||||
return p.then(authorInfo => {
|
// default fallback color to use if authorInfo.colorId is null
|
||||||
// default fallback color to use if authorInfo.colorId is null
|
const defaultColor = "#daf0b2";
|
||||||
const defaultColor = "#daf0b2";
|
|
||||||
|
|
||||||
if (!authorInfo) {
|
if (!authorInfo) {
|
||||||
console.warn(`handleClientReady(): no authorInfo parameter was received. Default values are going to be used. See issue #3612. This can be caused by a user clicking undo after clearing all authorship colors see #2802`);
|
console.warn(`handleClientReady(): no authorInfo parameter was received. Default values are going to be used. See issue #3612. This can be caused by a user clicking undo after clearing all authorship colors see #2802`);
|
||||||
authorInfo = {};
|
authorInfo = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
// For some reason sometimes name isn't set
|
// For some reason sometimes name isn't set
|
||||||
// Catch this issue here and use a fixed name.
|
// Catch this issue here and use a fixed name.
|
||||||
if (!authorInfo.name) {
|
if (!authorInfo.name) {
|
||||||
console.warn(`handleClientReady(): client submitted no author name. Using "Anonymous". See: issue #3612`);
|
console.warn(`handleClientReady(): client submitted no author name. Using "Anonymous". See: issue #3612`);
|
||||||
authorInfo.name = "Anonymous";
|
authorInfo.name = "Anonymous";
|
||||||
}
|
}
|
||||||
|
|
||||||
// For some reason sometimes colorId isn't set
|
// For some reason sometimes colorId isn't set
|
||||||
// Catch this issue here and use a fixed color.
|
// Catch this issue here and use a fixed color.
|
||||||
if (!authorInfo.colorId) {
|
if (!authorInfo.colorId) {
|
||||||
console.warn(`handleClientReady(): author "${authorInfo.name}" has no property colorId. Using the default color ${defaultColor}. See issue #3612`);
|
console.warn(`handleClientReady(): author "${authorInfo.name}" has no property colorId. Using the default color ${defaultColor}. See issue #3612`);
|
||||||
authorInfo.colorId = defaultColor;
|
authorInfo.colorId = defaultColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send the new User a Notification about this other user
|
// Send the new User a Notification about this other user
|
||||||
let msg = {
|
let msg = {
|
||||||
"type": "COLLABROOM",
|
"type": "COLLABROOM",
|
||||||
"data": {
|
"data": {
|
||||||
type: "USER_NEWINFO",
|
type: "USER_NEWINFO",
|
||||||
userInfo: {
|
userInfo: {
|
||||||
"ip": "127.0.0.1",
|
"ip": "127.0.0.1",
|
||||||
"colorId": authorInfo.colorId,
|
"colorId": authorInfo.colorId,
|
||||||
"name": authorInfo.name,
|
"name": authorInfo.name,
|
||||||
"userAgent": "Anonymous",
|
"userAgent": "Anonymous",
|
||||||
"userId": author
|
"userId": author
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
};
|
||||||
|
|
||||||
client.json.send(msg);
|
client.json.send(msg);
|
||||||
});
|
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue