mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-01-19 14:13:34 +01:00
PadMessageHandler: Improve readability
This commit is contained in:
parent
019e296c4a
commit
d8cbd134d3
1 changed files with 14 additions and 31 deletions
|
@ -1256,39 +1256,22 @@ const getChangesetInfo = async (padId, startNum, endNum, granularity) => {
|
||||||
revTimesNeeded.push(end - 1);
|
revTimesNeeded.push(end - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// get all needed db values parallel - no await here since
|
// Get all needed db values in parallel.
|
||||||
// it would make all the lookups run in series
|
|
||||||
|
|
||||||
// get all needed composite Changesets
|
|
||||||
const composedChangesets = {};
|
const composedChangesets = {};
|
||||||
const p1 = Promise.all(
|
|
||||||
compositesChangesetNeeded.map(
|
|
||||||
(item) => composePadChangesets(
|
|
||||||
padId, item.start, item.end
|
|
||||||
).then(
|
|
||||||
(changeset) => {
|
|
||||||
composedChangesets[`${item.start}/${item.end}`] = changeset;
|
|
||||||
}
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
// get all needed revision Dates
|
|
||||||
const revisionDate = [];
|
const revisionDate = [];
|
||||||
const p2 = Promise.all(revTimesNeeded.map((revNum) => pad.getRevisionDate(revNum)
|
const [lines] = await Promise.all([
|
||||||
.then((revDate) => {
|
getPadLines(padId, startNum - 1),
|
||||||
revisionDate[revNum] = Math.floor(revDate / 1000);
|
// Get all needed composite Changesets.
|
||||||
})
|
...compositesChangesetNeeded.map(async (item) => {
|
||||||
));
|
const changeset = await composePadChangesets(padId, item.start, item.end);
|
||||||
|
composedChangesets[`${item.start}/${item.end}`] = changeset;
|
||||||
// get the lines
|
}),
|
||||||
let lines;
|
// Get all needed revision Dates.
|
||||||
const p3 = getPadLines(padId, startNum - 1).then((_lines) => {
|
...revTimesNeeded.map(async (revNum) => {
|
||||||
lines = _lines;
|
const revDate = await pad.getRevisionDate(revNum);
|
||||||
});
|
revisionDate[revNum] = Math.floor(revDate / 1000);
|
||||||
|
}),
|
||||||
// wait for all of the above to complete
|
]);
|
||||||
await Promise.all([p1, p2, p3]);
|
|
||||||
|
|
||||||
// doesn't know what happens here exactly :/
|
// doesn't know what happens here exactly :/
|
||||||
const timeDeltas = [];
|
const timeDeltas = [];
|
||||||
|
|
Loading…
Reference in a new issue