@@ -68,7 +68,9 @@ type HandleChannelHiddenParameters<SCG extends ExtendableGenerics> = BaseParamet
6868 RepeatedParameters < SCG > ;
6969
7070type HandleChannelVisibleParameters < SCG extends ExtendableGenerics > =
71- BaseParameters < SCG > & RepeatedParameters < SCG > ;
71+ BaseParameters < SCG > &
72+ RepeatedParameters < SCG > &
73+ Required < Pick < ChannelListProps < SCG > , 'sort' | 'filters' > > ;
7274
7375type HandleChannelTruncatedParameters < SCG extends ExtendableGenerics > =
7476 BaseParameters < SCG > & RepeatedParameters < SCG > ;
@@ -194,7 +196,6 @@ export const useChannelListShapeDefaults = <SCG extends ExtendableGenerics>() =>
194196 moveChannelUpwards ( {
195197 channels,
196198 channelToMove : channel ,
197- channelToMoveIndexWithinChannels : - 1 ,
198199 sort,
199200 } ) ,
200201 ) ;
@@ -353,20 +354,36 @@ export const useChannelListShapeDefaults = <SCG extends ExtendableGenerics>() =>
353354 async ( {
354355 customHandler,
355356 event,
357+ filters,
356358 setChannels,
359+ sort,
357360 } : HandleChannelVisibleParameters < SCG > ) => {
358361 if ( typeof customHandler === 'function' ) {
359362 return customHandler ( setChannels , event ) ;
360363 }
361364
362- if ( event . type && event . channel_type && event . channel_id ) {
363- const channel = await getChannel ( {
364- client,
365- id : event . channel_id ,
366- type : event . channel_type ,
367- } ) ;
368- setChannels ( ( channels ) => uniqBy ( [ channel , ...channels ] , 'cid' ) ) ;
365+ if ( ! event . channel ) {
366+ return ;
367+ }
368+
369+ const channel = await getChannel ( {
370+ client,
371+ id : event . channel . id ,
372+ type : event . channel . type ,
373+ } ) ;
374+
375+ const considerArchivedChannels = shouldConsiderArchivedChannels ( filters ) ;
376+ if ( isChannelArchived ( channel ) && considerArchivedChannels && ! filters . archived ) {
377+ return ;
369378 }
379+
380+ setChannels ( ( channels ) =>
381+ moveChannelUpwards ( {
382+ channels,
383+ channelToMove : channel ,
384+ sort,
385+ } ) ,
386+ ) ;
370387 } ,
371388 [ client ] ,
372389 ) ;
@@ -586,7 +603,9 @@ export const usePrepareShapeHandlers = <SCG extends ExtendableGenerics>({
586603 defaults . handleChannelVisible ( {
587604 customHandler : onChannelVisible ,
588605 event,
606+ filters,
589607 setChannels,
608+ sort
590609 } ) ;
591610 break ;
592611 case 'channel.truncated' :
0 commit comments