From 7a4797e3db867f936a2cb213716ef3aa318736df Mon Sep 17 00:00:00 2001 From: Ahyoung Ryu Date: Tue, 18 Jun 2024 11:04:13 +0900 Subject: [PATCH] [CLNP-3775] fix: reset new messages on scroll bottom reached (#1138) Fixes https://sendbird.atlassian.net/browse/SBISSUE-16266 The `newMessages` array was not being reset even after the message list scroll reached the bottom. This issue was causing the message notification bar to not disappear properly. To address the issue, I manually called `resetNewMessages()` under certain conditions. --- .../GroupChannel/components/MessageList/index.tsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/modules/GroupChannel/components/MessageList/index.tsx b/src/modules/GroupChannel/components/MessageList/index.tsx index 9f1dc85e9f..e16e8e3b45 100644 --- a/src/modules/GroupChannel/components/MessageList/index.tsx +++ b/src/modules/GroupChannel/components/MessageList/index.tsx @@ -84,6 +84,7 @@ export const MessageList = (props: GroupChannelMessageListProps) => { loadNext, loadPrevious, setIsScrollBottomReached, + resetNewMessages, } = useGroupChannelContext(); const store = useSendbirdStateContext(); @@ -167,7 +168,13 @@ export const MessageList = (props: GroupChannelMessageListProps) => { scrollDistanceFromBottomRef={scrollDistanceFromBottomRef} onLoadNext={loadNext} onLoadPrevious={loadPrevious} - onScrollPosition={(it) => setIsScrollBottomReached(it === 'bottom')} + onScrollPosition={(it) => { + const isScrollBottomReached = it === 'bottom'; + if (newMessages.length > 0 && isScrollBottomReached) { + resetNewMessages(); + } + setIsScrollBottomReached(isScrollBottomReached); + }} messages={messages} renderMessage={({ message, index }) => { const { chainTop, chainBottom, hasSeparator } = getMessagePartsInfo({