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

This commit is contained in:
Scott Nonnenberg 2022-04-20 12:31:54 -07:00 committed by GitHub
parent 7821a872bd
commit 34a27accfc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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();
}
}