From 149b7d4f8b62897440b251df3c506f201c061b79 Mon Sep 17 00:00:00 2001 From: trevor-signal <131492920+trevor-signal@users.noreply.github.com> Date: Wed, 16 Jul 2025 12:34:37 -0400 Subject: [PATCH] Allow passing newest read message explicitly --- ts/components/conversation/Timeline.tsx | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/ts/components/conversation/Timeline.tsx b/ts/components/conversation/Timeline.tsx index 5751a5ee1e..c55f4427ec 100644 --- a/ts/components/conversation/Timeline.tsx +++ b/ts/components/conversation/Timeline.tsx @@ -452,7 +452,9 @@ export class Timeline extends React.Component< setIsNearBottom(id, newIsNearBottom); if (newestBottomVisibleMessageId) { - this.#markNewestBottomVisibleMessageRead(); + this.#markNewestBottomVisibleMessageRead( + newestBottomVisibleMessageId + ); const rowIndex = getRowIndexFromElement(newestBottomVisible); const maxRowIndex = items.length - 1; @@ -506,11 +508,12 @@ export class Timeline extends React.Component< this.#intersectionObserver.observe(atBottomDetectorEl); } - #markNewestBottomVisibleMessageRead = throttle((): void => { + #markNewestBottomVisibleMessageRead = throttle((messageId?: string): void => { const { id, markMessageRead } = this.props; - const { newestBottomVisibleMessageId } = this.state; - if (newestBottomVisibleMessageId) { - markMessageRead(id, newestBottomVisibleMessageId); + const messageIdToMarkRead = + messageId ?? this.state.newestBottomVisibleMessageId; + if (messageIdToMarkRead) { + markMessageRead(id, messageIdToMarkRead); } }, 500);