Skip to content

Commit

Permalink
[CLNP-3775] fix: reset new messages on scroll bottom reached (#1138)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
AhyoungRyu authored Jun 18, 2024
1 parent a8297f6 commit 7a4797e
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/modules/GroupChannel/components/MessageList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ export const MessageList = (props: GroupChannelMessageListProps) => {
loadNext,
loadPrevious,
setIsScrollBottomReached,
resetNewMessages,
} = useGroupChannelContext();

const store = useSendbirdStateContext();
Expand Down Expand Up @@ -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({
Expand Down

0 comments on commit 7a4797e

Please sign in to comment.