* @param {number} start - ID of the first desired chat message. * @param {number} end - ID of the last desired chat message. * @returns {ChatMessage[]} Any existing messages with IDs between `start` (inclusive) and `end` * (inclusive), in order. Note: `start` and `end` form a closed int
(start: string, end: number)
| 566 | * interval as is typical in code. |
| 567 | */ |
| 568 | async getChatMessages(start: string, end: number) { |
| 569 | const entries = |
| 570 | await Promise.all(Stream.range(start, end + 1).map(this.getChatMessage.bind(this))); |
| 571 | |
| 572 | // sort out broken chat entries |
| 573 | // it looks like in happened in the past that the chat head was |
| 574 | // incremented, but the chat message wasn't added |
| 575 | return entries.filter((entry) => { |
| 576 | const pass = (entry != null); |
| 577 | if (!pass) { |
| 578 | console.warn(`WARNING: Found broken chat entry in pad ${this.id}`); |
| 579 | } |
| 580 | return pass; |
| 581 | }); |
| 582 | } |
| 583 | |
| 584 | async init(text:string, authorId = '') { |
| 585 | // try to load the pad |
no test coverage detected