From 71fb4eb4e3725353d72268d8a046c553b9eb367c Mon Sep 17 00:00:00 2001 From: automated-signal <37887102+automated-signal@users.noreply.github.com> Date: Wed, 20 Apr 2022 16:34:34 -0700 Subject: [PATCH] Timeline: Mark messages read sooner, and a little more often Co-authored-by: Scott Nonnenberg --- ts/components/conversation/Timeline.tsx | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/ts/components/conversation/Timeline.tsx b/ts/components/conversation/Timeline.tsx index fc6dc61da2..9c00733150 100644 --- a/ts/components/conversation/Timeline.tsx +++ b/ts/components/conversation/Timeline.tsx @@ -541,17 +541,13 @@ export class Timeline extends React.Component< this.intersectionObserver.observe(atBottomDetectorEl); } - private markNewestBottomVisibleMessageRead = throttle( - (): void => { - const { markMessageRead } = this.props; - const { newestBottomVisibleMessageId } = this.state; - if (newestBottomVisibleMessageId) { - markMessageRead(newestBottomVisibleMessageId); - } - }, - 500, - { leading: false } - ); + private markNewestBottomVisibleMessageRead = throttle((): void => { + const { markMessageRead } = this.props; + const { newestBottomVisibleMessageId } = this.state; + if (newestBottomVisibleMessageId) { + markMessageRead(newestBottomVisibleMessageId); + } + }, 500); public override componentDidMount(): void { const containerEl = this.containerRef.current; @@ -674,6 +670,8 @@ export class Timeline extends React.Component< numberToKeepAtBottom: this.maxVisibleRows, }); } + } else { + this.markNewestBottomVisibleMessageRead(); } }