Skip to content

Commit 07915a5

Browse files
authored
fix: Recreates the GroupChannelCollection when channelListQueryParams change (#1182)
[CLNP-4233](https://sendbird.atlassian.net/browse/CLNP-4233) ### Issue When customers used channelListQueryParams in GroupChannelList, the channel list was not refreshed with the new query parameters when their values were changed. ### Fix The channel list now refreshes when the values of channelListQueryParams are changed. [CLNP-4233]: https://sendbird.atlassian.net/browse/CLNP-4233?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
1 parent adc74ee commit 07915a5

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/modules/GroupChannelList/context/GroupChannelListProvider.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export interface GroupChannelListContextType extends ContextBaseType, ChannelLis
4848
}
4949
export interface GroupChannelListProviderProps
5050
extends PartialRequired<ContextBaseType, 'onChannelSelect' | 'onChannelCreated'>,
51-
Pick<UserProfileProviderProps, 'onUserProfileMessage' | 'renderUserProfile' | 'disableUserProfile'> {
51+
Pick<UserProfileProviderProps, 'onUserProfileMessage' | 'renderUserProfile' | 'disableUserProfile'> {
5252
children?: React.ReactNode;
5353
}
5454

@@ -103,6 +103,15 @@ export const GroupChannelListProvider = (props: GroupChannelListProviderProps) =
103103
}
104104
}, [disableAutoSelect, stores.sdkStore.initialized, initialized, selectedChannelUrl]);
105105

106+
// Recreates the GroupChannelCollection when `channelListQueryParams` change
107+
useEffect(() => {
108+
refresh();
109+
}, [
110+
Object.keys(channelListQueryParams ?? {}).sort()
111+
.map((key: string) => `${key}=${encodeURIComponent(JSON.stringify(channelListQueryParams[key]))}`)
112+
.join('&'),
113+
]);
114+
106115
const [typingChannelUrls, setTypingChannelUrls] = useState<string[]>([]);
107116
useGroupChannelHandler(sdk, {
108117
onTypingStatusUpdated: (channel) => {

0 commit comments

Comments
 (0)