Timeline: Mark messages read sooner, and a little more often

Co-authored-by: Scott Nonnenberg <scott@signal.org>
This commit is contained in:
automated-signal 2022-04-20 16:34:34 -07:00 committed by GitHub
parent a384d7bcdf
commit 71fb4eb4e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 11 deletions

View File

@ -541,17 +541,13 @@ export class Timeline extends React.Component<
this.intersectionObserver.observe(atBottomDetectorEl); this.intersectionObserver.observe(atBottomDetectorEl);
} }
private markNewestBottomVisibleMessageRead = throttle( private markNewestBottomVisibleMessageRead = throttle((): void => {
(): void => { const { markMessageRead } = this.props;
const { markMessageRead } = this.props; const { newestBottomVisibleMessageId } = this.state;
const { newestBottomVisibleMessageId } = this.state; if (newestBottomVisibleMessageId) {
if (newestBottomVisibleMessageId) { markMessageRead(newestBottomVisibleMessageId);
markMessageRead(newestBottomVisibleMessageId); }
} }, 500);
},
500,
{ leading: false }
);
public override componentDidMount(): void { public override componentDidMount(): void {
const containerEl = this.containerRef.current; const containerEl = this.containerRef.current;
@ -674,6 +670,8 @@ export class Timeline extends React.Component<
numberToKeepAtBottom: this.maxVisibleRows, numberToKeepAtBottom: this.maxVisibleRows,
}); });
} }
} else {
this.markNewestBottomVisibleMessageRead();
} }
} }