Skip to content

Commit 559c4c0

Browse files
committed
fix: unread message indicator on small message list
1 parent a063caf commit 559c4c0

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

package/src/components/MessageList/MessageList.tsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,14 @@ const MessageListWithContext = <
413413
const unreadIndicatorDate = channelUnreadState?.last_read.getTime();
414414
const lastItemDate = lastItemCreatedAt.getTime();
415415

416+
if (
417+
!channel.state.messagePagination.hasPrev &&
418+
processedMessageList[processedMessageList.length - 1].id === lastItem.item.id
419+
) {
420+
setIsUnreadNotificationOpen(false);
421+
return;
422+
}
423+
416424
if (unreadIndicatorDate && lastItemDate > unreadIndicatorDate) {
417425
setIsUnreadNotificationOpen(true);
418426
} else {
@@ -466,8 +474,7 @@ const MessageListWithContext = <
466474
return () => {
467475
listener?.unsubscribe();
468476
};
469-
// eslint-disable-next-line react-hooks/exhaustive-deps
470-
}, []);
477+
}, [channel, markRead, scrollToBottomButtonVisible]);
471478

472479
useEffect(() => {
473480
const lastReceivedMessage = getLastReceivedMessage(processedMessageList);
@@ -636,7 +643,7 @@ const MessageListWithContext = <
636643
{renderMessage}
637644
</View>
638645
)}
639-
{showUnreadSeparator && <InlineUnreadIndicator />}
646+
{showUnreadUnderlay && <InlineUnreadIndicator />}
640647
</View>
641648
);
642649
};

0 commit comments

Comments
 (0)