Allow passing newest read message explicitly
This commit is contained in:
parent
b30c53d291
commit
149b7d4f8b
1 changed files with 8 additions and 5 deletions
|
@ -452,7 +452,9 @@ export class Timeline extends React.Component<
|
||||||
setIsNearBottom(id, newIsNearBottom);
|
setIsNearBottom(id, newIsNearBottom);
|
||||||
|
|
||||||
if (newestBottomVisibleMessageId) {
|
if (newestBottomVisibleMessageId) {
|
||||||
this.#markNewestBottomVisibleMessageRead();
|
this.#markNewestBottomVisibleMessageRead(
|
||||||
|
newestBottomVisibleMessageId
|
||||||
|
);
|
||||||
|
|
||||||
const rowIndex = getRowIndexFromElement(newestBottomVisible);
|
const rowIndex = getRowIndexFromElement(newestBottomVisible);
|
||||||
const maxRowIndex = items.length - 1;
|
const maxRowIndex = items.length - 1;
|
||||||
|
@ -506,11 +508,12 @@ export class Timeline extends React.Component<
|
||||||
this.#intersectionObserver.observe(atBottomDetectorEl);
|
this.#intersectionObserver.observe(atBottomDetectorEl);
|
||||||
}
|
}
|
||||||
|
|
||||||
#markNewestBottomVisibleMessageRead = throttle((): void => {
|
#markNewestBottomVisibleMessageRead = throttle((messageId?: string): void => {
|
||||||
const { id, markMessageRead } = this.props;
|
const { id, markMessageRead } = this.props;
|
||||||
const { newestBottomVisibleMessageId } = this.state;
|
const messageIdToMarkRead =
|
||||||
if (newestBottomVisibleMessageId) {
|
messageId ?? this.state.newestBottomVisibleMessageId;
|
||||||
markMessageRead(id, newestBottomVisibleMessageId);
|
if (messageIdToMarkRead) {
|
||||||
|
markMessageRead(id, messageIdToMarkRead);
|
||||||
}
|
}
|
||||||
}, 500);
|
}, 500);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue