@@ -33,6 +33,8 @@ import type { DefaultStreamChatGenerics } from '../../types/types';
3333import { ChannelPreviewMessenger } from '../ChannelPreview/ChannelPreviewMessenger' ;
3434import { EmptyStateIndicator as EmptyStateIndicatorDefault } from '../Indicators/EmptyStateIndicator' ;
3535import { LoadingErrorIndicator as LoadingErrorIndicatorDefault } from '../Indicators/LoadingErrorIndicator' ;
36+ import { shouldConsiderArchivedChannels } from './hooks/utils' ;
37+ import { useChannelMemberUpdated } from './hooks/listeners/useMemberUpdated' ;
3638
3739export type ChannelListProps <
3840 StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics ,
@@ -163,13 +165,14 @@ export type ChannelListProps<
163165 * @param lockChannelOrder If set to true, channels won't dynamically sort by most recent message, defaults to false
164166 * @param setChannels Setter for internal state property - `channels`. It's created from useState() hook.
165167 * @param event An [Event object](https://getstream.io/chat/docs/event_object) corresponding to `message.new` event
166- *
168+ * @param considerArchivedChannels If set to true, archived channels will be considered while updating the list of channels
167169 * @overrideType Function
168170 * */
169171 onNewMessage ?: (
170172 lockChannelOrder : boolean ,
171173 setChannels : React . Dispatch < React . SetStateAction < Channel < StreamChatGenerics > [ ] | null > > ,
172174 event : Event < StreamChatGenerics > ,
175+ considerArchivedChannels ?: boolean ,
173176 ) => void ;
174177 /**
175178 * Override the default listener/handler for event `notification.message_new`
@@ -183,6 +186,7 @@ export type ChannelListProps<
183186 onNewMessageNotification ?: (
184187 setChannels : React . Dispatch < React . SetStateAction < Channel < StreamChatGenerics > [ ] | null > > ,
185188 event : Event < StreamChatGenerics > ,
189+ considerArchivedChannels ?: boolean ,
186190 ) => void ;
187191 /**
188192 * Function that overrides default behavior when a user gets removed from a channel
@@ -286,6 +290,8 @@ export const ChannelList = <
286290 sort,
287291 } ) ;
288292
293+ const considerArchivedChannels = shouldConsiderArchivedChannels ( filters ) ;
294+
289295 // Setup event listeners
290296 useAddedToChannelNotification ( {
291297 onAddedToChannel,
@@ -323,11 +329,13 @@ export const ChannelList = <
323329 lockChannelOrder,
324330 onNewMessage,
325331 setChannels,
332+ considerArchivedChannels,
326333 } ) ;
327334
328335 useNewMessageNotification ( {
329336 onNewMessageNotification,
330337 setChannels,
338+ considerArchivedChannels,
331339 } ) ;
332340
333341 useRemovedFromChannelNotification ( {
@@ -340,6 +348,10 @@ export const ChannelList = <
340348 setForceUpdate,
341349 } ) ;
342350
351+ useChannelMemberUpdated ( {
352+ setChannels,
353+ } ) ;
354+
343355 const channelIdsStr = channels ?. reduce ( ( acc , channel ) => `${ acc } ${ channel . cid } ` , '' ) ;
344356
345357 useEffect ( ( ) => {
0 commit comments