PadMessageHandler: Improve readability of changeset loading

pull/5255/head
Richard Hansen 2021-10-30 01:16:17 -04:00
parent 50b9e0df1f
commit 00e7b04518
1 changed files with 7 additions and 8 deletions

View File

@ -905,15 +905,14 @@ const handleClientReady = async (socket, message) => {
changesets[r] = {};
}
// get changesets, author and timestamp needed for pending revisions (in parallel)
const promises = [];
for (const revNum of revisionsNeeded) {
await Promise.all(revisionsNeeded.map(async (revNum) => {
const cs = changesets[revNum];
promises.push(pad.getRevisionChangeset(revNum).then((result) => cs.changeset = result));
promises.push(pad.getRevisionAuthor(revNum).then((result) => cs.author = result));
promises.push(pad.getRevisionDate(revNum).then((result) => cs.timestamp = result));
}
await Promise.all(promises);
[cs.changeset, cs.author, cs.timestamp] = await Promise.all([
pad.getRevisionChangeset(revNum),
pad.getRevisionAuthor(revNum),
pad.getRevisionDate(revNum),
]);
}));
// return pending changesets
for (const r of revisionsNeeded) {