Skip to content

Commit

Permalink
Timeline: Mark messages read sooner, and a little more often
Browse files Browse the repository at this point in the history
Co-authored-by: Scott Nonnenberg <scott@signal.org>
  • Loading branch information
automated-signal and scottnonnenberg-signal committed Apr 20, 2022
1 parent a384d7b commit 71fb4eb
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions ts/components/conversation/Timeline.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -674,6 +670,8 @@ export class Timeline extends React.Component<
numberToKeepAtBottom: this.maxVisibleRows,
});
}
} else {
this.markNewestBottomVisibleMessageRead();
}
}

Expand Down

0 comments on commit 71fb4eb

Please sign in to comment.