Skip to content

Commit 503e9c8

Browse files
authored
fix: respect read events for unread notification display in Message Lists (#3234)
1 parent c935387 commit 503e9c8

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

package/src/components/MessageList/MessageFlashList.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ import {
3636
MessagesContextValue,
3737
useMessagesContext,
3838
} from '../../contexts/messagesContext/MessagesContext';
39+
import {
40+
OwnCapabilitiesContextValue,
41+
useOwnCapabilitiesContext,
42+
} from '../../contexts/ownCapabilitiesContext/OwnCapabilitiesContext';
3943
import {
4044
PaginatedMessageListContextValue,
4145
usePaginatedMessageListContext,
@@ -93,6 +97,7 @@ type MessageFlashListPropsWithContext = Pick<
9397
AttachmentPickerContextValue,
9498
'closePicker' | 'selectedPicker' | 'setSelectedPicker'
9599
> &
100+
Pick<OwnCapabilitiesContextValue, 'readEvents'> &
96101
Pick<
97102
ChannelContextValue,
98103
| 'channel'
@@ -269,6 +274,7 @@ const MessageFlashListWithContext = (props: MessageFlashListPropsWithContext) =>
269274
Message,
270275
MessageSystem,
271276
myMessageTheme,
277+
readEvents,
272278
NetworkDownIndicator,
273279
noGroupByUser,
274280
onListScroll,
@@ -630,7 +636,7 @@ const MessageFlashListWithContext = (props: MessageFlashListPropsWithContext) =>
630636
* This function should show or hide the unread indicator depending on the
631637
*/
632638
const updateStickyUnreadIndicator = useStableCallback((viewableItems: ViewToken[]) => {
633-
if (!viewableItems.length) {
639+
if (!viewableItems.length || !readEvents) {
634640
setIsUnreadNotificationOpen(false);
635641
return;
636642
}
@@ -1227,6 +1233,7 @@ export const MessageFlashList = (props: MessageFlashListProps) => {
12271233
} = useMessagesContext();
12281234
const { loadMore, loadMoreRecent } = usePaginatedMessageListContext();
12291235
const { loadMoreRecentThread, loadMoreThread, thread, threadInstance } = useThreadContext();
1236+
const { readEvents } = useOwnCapabilitiesContext();
12301237

12311238
return (
12321239
<MessageFlashListWithContext
@@ -1260,6 +1267,7 @@ export const MessageFlashList = (props: MessageFlashListProps) => {
12601267
MessageSystem,
12611268
myMessageTheme,
12621269
NetworkDownIndicator,
1270+
readEvents,
12631271
reloadChannel,
12641272
ScrollToBottomButton,
12651273
scrollToFirstUnreadThreshold,

package/src/components/MessageList/MessageList.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ import {
3737
MessagesContextValue,
3838
useMessagesContext,
3939
} from '../../contexts/messagesContext/MessagesContext';
40+
import {
41+
OwnCapabilitiesContextValue,
42+
useOwnCapabilitiesContext,
43+
} from '../../contexts/ownCapabilitiesContext/OwnCapabilitiesContext';
4044
import {
4145
PaginatedMessageListContextValue,
4246
usePaginatedMessageListContext,
@@ -115,6 +119,7 @@ type MessageListPropsWithContext = Pick<
115119
AttachmentPickerContextValue,
116120
'closePicker' | 'selectedPicker' | 'setSelectedPicker'
117121
> &
122+
Pick<OwnCapabilitiesContextValue, 'readEvents'> &
118123
Pick<
119124
ChannelContextValue,
120125
| 'channel'
@@ -277,6 +282,7 @@ const MessageListWithContext = (props: MessageListPropsWithContext) => {
277282
noGroupByUser,
278283
onListScroll,
279284
onThreadSelect,
285+
readEvents,
280286
reloadChannel,
281287
ScrollToBottomButton,
282288
selectedPicker,
@@ -441,7 +447,7 @@ const MessageListWithContext = (props: MessageListPropsWithContext) => {
441447
}
442448
messagesLength.current = processedMessageList.length;
443449

444-
if (!viewableItems.length) {
450+
if (!viewableItems.length || !readEvents) {
445451
setIsUnreadNotificationOpen(false);
446452
return;
447453
}
@@ -1294,6 +1300,7 @@ export const MessageList = (props: MessageListProps) => {
12941300
} = useChannelContext();
12951301
const { client } = useChatContext();
12961302
const { setMessages } = useImageGalleryContext();
1303+
const { readEvents } = useOwnCapabilitiesContext();
12971304
const {
12981305
DateHeader,
12991306
disableTypingIndicator,
@@ -1345,6 +1352,7 @@ export const MessageList = (props: MessageListProps) => {
13451352
MessageSystem,
13461353
myMessageTheme,
13471354
NetworkDownIndicator,
1355+
readEvents,
13481356
reloadChannel,
13491357
ScrollToBottomButton,
13501358
scrollToFirstUnreadThreshold,

0 commit comments

Comments
 (0)