optimize timeline scroll performance
This commit is contained in:
parent
1143c0e9ba
commit
e5635726ac
1 changed files with 19 additions and 4 deletions
|
@ -399,12 +399,14 @@ export class Timeline extends React.Component<
|
||||||
const newestBottomVisibleMessageId =
|
const newestBottomVisibleMessageId =
|
||||||
getMessageIdFromElement(newestBottomVisible);
|
getMessageIdFromElement(newestBottomVisible);
|
||||||
|
|
||||||
this.setState({
|
this.updatePartiallyVisibleMessageIds(
|
||||||
oldestPartiallyVisibleMessageId,
|
oldestPartiallyVisibleMessageId,
|
||||||
newestBottomVisibleMessageId,
|
newestBottomVisibleMessageId
|
||||||
});
|
);
|
||||||
|
|
||||||
|
if (this.props.isNearBottom !== newIsNearBottom) {
|
||||||
setIsNearBottom(id, newIsNearBottom);
|
setIsNearBottom(id, newIsNearBottom);
|
||||||
|
}
|
||||||
|
|
||||||
if (newestBottomVisibleMessageId) {
|
if (newestBottomVisibleMessageId) {
|
||||||
this.markNewestBottomVisibleMessageRead();
|
this.markNewestBottomVisibleMessageRead();
|
||||||
|
@ -461,6 +463,19 @@ export class Timeline extends React.Component<
|
||||||
this.intersectionObserver.observe(atBottomDetectorEl);
|
this.intersectionObserver.observe(atBottomDetectorEl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private updatePartiallyVisibleMessageIds = throttle(
|
||||||
|
(
|
||||||
|
oldestPartiallyVisibleMessageId: string | undefined,
|
||||||
|
newestBottomVisibleMessageId: string | undefined
|
||||||
|
) => {
|
||||||
|
this.setState({
|
||||||
|
oldestPartiallyVisibleMessageId,
|
||||||
|
newestBottomVisibleMessageId,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
100
|
||||||
|
);
|
||||||
|
|
||||||
private markNewestBottomVisibleMessageRead = throttle((): void => {
|
private markNewestBottomVisibleMessageRead = throttle((): void => {
|
||||||
const { id, markMessageRead } = this.props;
|
const { id, markMessageRead } = this.props;
|
||||||
const { newestBottomVisibleMessageId } = this.state;
|
const { newestBottomVisibleMessageId } = this.state;
|
||||||
|
|
Loading…
Reference in a new issue