* Adds a chat message to the pad, including saving it to the database. * * @param {(ChatMessage|string)} msgOrText - Either a chat message object (recommended) or a * string containing the raw text of the user's chat message (deprecated). * @param {?string} [authorId] - The user's au
(msgOrText: string| ChatMessage, authorId = null, time = null)
| 534 | * `msgOrText.time` instead. |
| 535 | */ |
| 536 | async appendChatMessage(msgOrText: string| ChatMessage, authorId = null, time = null) { |
| 537 | const msg = |
| 538 | msgOrText instanceof ChatMessage ? msgOrText : new ChatMessage(msgOrText, authorId, time); |
| 539 | this.chatHead++; |
| 540 | await Promise.all([ |
| 541 | // Don't save the display name in the database because the user can change it at any time. The |
| 542 | // `displayName` property will be populated with the current value when the message is read |
| 543 | // from the database. |
| 544 | this.db.set(`pad:${this.id}:chat:${this.chatHead}`, {...msg, displayName: undefined}), |
| 545 | this.saveToDatabase(), |
| 546 | ]); |
| 547 | } |
| 548 | |
| 549 | /** |
| 550 | * @param {number} entryNum - ID of the desired chat message. |
no test coverage detected