Roomlogs: Don't count certain protocol messages for Room#nthMessageHandlers

Previously, join/leave/userstats/etc would all count against the nthMessageHandlers (which is relevant for repeats), and this is most definitely incorrect behavior.
This commit is contained in:
Mia 2021-09-15 12:56:39 -05:00
parent 73696f5d71
commit 866722f70d

View File

@ -56,6 +56,7 @@ export class Roomlog {
* Scrollback log
*/
log: string[];
visibleMessageCount = 0;
broadcastBuffer: string[];
/**
* undefined = uninitialized,
@ -143,6 +144,11 @@ export class Roomlog {
}
add(message: string) {
this.roomlog(message);
// |uhtml gets both uhtml and uhtmlchange
// which are visible and so should be counted
if (['|c|', '|c:|', '|raw|', '|html|', '|uhtml'].some(k => message.startsWith(k))) {
this.visibleMessageCount++;
}
message = this.withTimestamp(message);
this.log.push(message);
this.broadcastBuffer.push(message);
@ -275,8 +281,8 @@ export class Roomlog {
/**
* Returns the total number of lines in the roomlog, including truncated lines.
*/
getLineCount() {
return this.log.length + this.numTruncatedLines;
getLineCount(onlyVisible = true) {
return (onlyVisible ? this.visibleMessageCount : this.log.length) + this.numTruncatedLines;
}
destroy() {