Skip to content

Commit c1f6bab

Browse files
committed
Address feedback
1 parent 845b872 commit c1f6bab

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/modules/GroupChannel/components/MessageList/InfiniteList.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ export const InfiniteList = forwardRef((props: Props, listRef: React.RefObject<H
8787
} else {
8888
direction.current = undefined;
8989
}
90-
}, [listRef.current, messages.length]);
90+
}, [messages.length]);
9191

9292
return (
9393
<div className="sendbird-conversation__scroll-container">

src/modules/GroupChannel/context/GroupChannelProvider.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,12 @@ const GroupChannelManager :React.FC<React.PropsWithChildren<GroupChannelProvider
145145
}
146146
},
147147
onMessagesReceived: (messages) => {
148-
if (isScrollBottomReached && isContextMenuClosed() && messages.length !== state.messages.length) {
148+
if (isScrollBottomReached
149+
&& isContextMenuClosed()
150+
// Note: this shouldn't happen ideally, but it happens on re-rendering GroupChannelManager
151+
// even though the next messages and the current messages length are the same.
152+
// So added this condition to check if they are the same to prevent unnecessary calling scrollToBottom action
153+
&& messages.length !== state.messages.length) {
149154
setTimeout(() => actions.scrollToBottom(true), 10);
150155
}
151156
},
@@ -158,6 +163,9 @@ const GroupChannelManager :React.FC<React.PropsWithChildren<GroupChannelProvider
158163
onBackClick?.();
159164
},
160165
onChannelUpdated: (channel) => {
166+
// Note: this shouldn't happen ideally, but it happens on re-rendering GroupChannelManager
167+
// even though the next channel and the current channel are the same.
168+
// So added this condition to check if they are the same to prevent unnecessary calling setCurrentChannel action
161169
if (!state.currentChannel?.isEqual(channel)) {
162170
actions.setCurrentChannel(channel);
163171
}

0 commit comments

Comments
 (0)