Skip to content

Commit 9f4279d

Browse files
committed
fix: visibility of unread notification and underlay in certain scenarios
1 parent 41940f0 commit 9f4279d

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

package/src/components/Channel/Channel.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1064,6 +1064,7 @@ const ChannelWithContext = (props: PropsWithChildren<ChannelPropsWithContext>) =
10641064
if (failedMessages?.length) {
10651065
channel.state.addMessagesSorted(failedMessages);
10661066
}
1067+
await markRead();
10671068
channel.state.setIsUpToDate(true);
10681069
} else {
10691070
await reloadThread();

package/src/components/MessageList/MessageList.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,10 +415,21 @@ const MessageListWithContext = (props: MessageListPropsWithContext) => {
415415
}
416416
});
417417

418+
const messagesLength = useRef<number>(processedMessageList.length);
419+
418420
/**
419421
* This function should show or hide the unread indicator depending on the
420422
*/
421423
const updateStickyUnreadIndicator = useStableCallback((viewableItems: ViewToken[]) => {
424+
// we need this check to make sure that regular list change do not trigger
425+
// the unread notification to appear (for example if the old last read messages
426+
// go out of the viewport).
427+
if (processedMessageList.length !== messagesLength.current) {
428+
setIsUnreadNotificationOpen(false);
429+
return;
430+
}
431+
messagesLength.current = processedMessageList.length;
432+
422433
if (!viewableItems.length) {
423434
setIsUnreadNotificationOpen(false);
424435
return;
@@ -737,10 +748,12 @@ const MessageListWithContext = (props: MessageListPropsWithContext) => {
737748
const isLastReadMessage =
738749
channelUnreadState?.last_read_message_id === message.id ||
739750
(!channelUnreadState?.unread_messages && createdAtTimestamp === lastReadTimestamp);
751+
const isMyMessage = message.user?.id === client.userID;
740752

741753
const showUnreadSeparator =
742754
isLastReadMessage &&
743755
!isNewestMessage &&
756+
!isMyMessage &&
744757
// The `channelUnreadState?.first_unread_message_id` is here for sent messages unread label
745758
(!!channelUnreadState?.first_unread_message_id || !!channelUnreadState?.unread_messages);
746759

0 commit comments

Comments
 (0)