Pad: Use the Stream library to improve readability
parent
7c6746612c
commit
8442e002f9
|
@ -327,8 +327,8 @@ class Pad {
|
||||||
* interval as is typical in code.
|
* interval as is typical in code.
|
||||||
*/
|
*/
|
||||||
async getChatMessages(start, end) {
|
async getChatMessages(start, end) {
|
||||||
const entries = await Promise.all(
|
const entries =
|
||||||
[...Array(end + 1 - start).keys()].map((i) => this.getChatMessage(start + i)));
|
await Promise.all(Stream.range(start, end + 1).map(this.getChatMessage.bind(this)));
|
||||||
|
|
||||||
// sort out broken chat entries
|
// sort out broken chat entries
|
||||||
// it looks like in happened in the past that the chat head was
|
// it looks like in happened in the past that the chat head was
|
||||||
|
@ -385,8 +385,8 @@ class Pad {
|
||||||
|
|
||||||
await Promise.all((function* () {
|
await Promise.all((function* () {
|
||||||
yield copyRecord('');
|
yield copyRecord('');
|
||||||
for (let i = 0; i <= this.head; ++i) yield copyRecord(`:revs:${i}`);
|
yield* Stream.range(0, this.head + 1).map((i) => copyRecord(`:revs:${i}`));
|
||||||
for (let i = 0; i <= this.chatHead; ++i) yield copyRecord(`:chat:${i}`);
|
yield* Stream.range(0, this.chatHead + 1).map((i) => copyRecord(`:chat:${i}`));
|
||||||
yield this.copyAuthorInfoToDestinationPad(destinationID);
|
yield this.copyAuthorInfoToDestinationPad(destinationID);
|
||||||
if (destGroupID) yield db.setSub(`group:${destGroupID}`, ['pads', destinationID], 1);
|
if (destGroupID) yield db.setSub(`group:${destGroupID}`, ['pads', destinationID], 1);
|
||||||
}).call(this));
|
}).call(this));
|
||||||
|
|
Loading…
Reference in New Issue