@@ -42,15 +42,17 @@ type HandleNotificationMessageNewParameters<SCG extends ExtendableGenerics> = Ba
4242 lockChannelOrder : boolean ;
4343 } & Required < Pick < ChannelListProps < SCG > , 'filters' | 'sort' > > ;
4444
45- type HandleNotificationRemovedFromChannelParameters < SCG extends ExtendableGenerics > =
46- BaseParameters < SCG > & RepeatedParameters < SCG > ;
45+ type HandleNotificationRemovedFromChannelParameters <
46+ SCG extends ExtendableGenerics
47+ > = BaseParameters < SCG > & RepeatedParameters < SCG > ;
4748
48- type HandleNotificationAddedToChannelParameters < SCG extends ExtendableGenerics > =
49- BaseParameters < SCG > &
50- RepeatedParameters < SCG > & {
51- allowNewMessagesFromUnfilteredChannels : boolean ;
52- lockChannelOrder : boolean ;
53- } & Required < Pick < ChannelListProps < SCG > , 'sort' > > ;
49+ type HandleNotificationAddedToChannelParameters <
50+ SCG extends ExtendableGenerics
51+ > = BaseParameters < SCG > &
52+ RepeatedParameters < SCG > & {
53+ allowNewMessagesFromUnfilteredChannels : boolean ;
54+ lockChannelOrder : boolean ;
55+ } & Required < Pick < ChannelListProps < SCG > , 'sort' > > ;
5456
5557type HandleMemberUpdatedParameters < SCG extends ExtendableGenerics > = BaseParameters < SCG > & {
5658 lockChannelOrder : boolean ;
@@ -99,12 +101,12 @@ export const useChannelListShapeDefaults = <SCG extends ExtendableGenerics>() =>
99101 const handleMessageNew = useCallback (
100102 ( {
101103 allowNewMessagesFromUnfilteredChannels,
102- filters,
103- sort,
104104 customHandler,
105105 event,
106+ filters,
106107 lockChannelOrder,
107108 setChannels,
109+ sort,
108110 } : HandleMessageNewParameters < SCG > ) => {
109111 if ( typeof customHandler === 'function' ) {
110112 return customHandler ( setChannels , event ) ;
@@ -159,11 +161,11 @@ export const useChannelListShapeDefaults = <SCG extends ExtendableGenerics>() =>
159161 const handleNotificationMessageNew = useCallback (
160162 async ( {
161163 allowNewMessagesFromUnfilteredChannels,
162- sort,
163- filters,
164164 customHandler,
165165 event,
166+ filters,
166167 setChannels,
168+ sort,
167169 } : HandleNotificationMessageNewParameters < SCG > ) => {
168170 if ( typeof customHandler === 'function' ) {
169171 return customHandler ( setChannels , event ) ;
@@ -246,7 +248,7 @@ export const useChannelListShapeDefaults = <SCG extends ExtendableGenerics>() =>
246248 ) ;
247249
248250 const handleMemberUpdated = useCallback (
249- ( { sort , event, lockChannelOrder, setChannels } : HandleMemberUpdatedParameters < SCG > ) => {
251+ ( { event, lockChannelOrder, setChannels, sort } : HandleMemberUpdatedParameters < SCG > ) => {
250252 if ( ! event . member ?. user || event . member . user . id !== client . userID || ! event . channel_type ) {
251253 return ;
252254 }
@@ -258,7 +260,7 @@ export const useChannelListShapeDefaults = <SCG extends ExtendableGenerics>() =>
258260 const considerPinnedChannels = shouldConsiderPinnedChannels ( sort ) ;
259261
260262 // TODO: extract this and consider single property sort object too
261- const pinnedAtSort = Array . isArray ( sort ) ? ( sort [ 0 ] ?. pinned_at ?? null ) : null ;
263+ const pinnedAtSort = Array . isArray ( sort ) ? sort [ 0 ] ?. pinned_at ?? null : null ;
262264
263265 setChannels ( ( currentChannels ) => {
264266 const targetChannel = client . channel ( channelType , channelId ) ;
@@ -448,17 +450,18 @@ type UseDefaultHandleChannelListShapeParameters<SCG extends ExtendableGenerics>
448450 | 'onMessageNewHandler'
449451 | 'onRemovedFromChannel'
450452 > & {
453+ setChannels : SetChannels < SCG > ;
451454 customHandleChannelListShape ?: ( data : {
452- defaults : ReturnType < typeof useChannelListShapeDefaults < SCG > > ;
455+ defaults : ReturnType < typeof useChannelListShapeDefaults > ;
453456 event : Event < SCG > ;
454457 setChannels : SetChannels < SCG > ;
455458 } ) => void ;
456- setChannels : SetChannels < SCG > ;
457459 } ;
458460
459461export const usePrepareShapeHandlers = < SCG extends ExtendableGenerics > ( {
460462 allowNewMessagesFromUnfilteredChannels,
461463 customHandleChannelListShape,
464+ filters,
462465 lockChannelOrder,
463466 onAddedToChannel,
464467 onChannelDeleted,
@@ -470,7 +473,6 @@ export const usePrepareShapeHandlers = <SCG extends ExtendableGenerics>({
470473 onMessageNewHandler,
471474 onRemovedFromChannel,
472475 setChannels,
473- filters,
474476 sort,
475477} : UseDefaultHandleChannelListShapeParameters < SCG > ) => {
476478 const defaults = useChannelListShapeDefaults < SCG > ( ) ;
@@ -480,6 +482,7 @@ export const usePrepareShapeHandlers = <SCG extends ExtendableGenerics>({
480482 const customHandleChannelListShapeRef = useRef < ( e : Event < SCG > ) => void > ( ) ;
481483
482484 customHandleChannelListShapeRef . current = ( event : Event < SCG > ) => {
485+ // @ts -expect-error can't use ReturnType<typeof useChannelListShapeDefaults<SCG>> until we upgrade prettier to at least v2.7.0
483486 customHandleChannelListShape ?.( { defaults, event, setChannels } ) ;
484487 } ;
485488
@@ -488,33 +491,33 @@ export const usePrepareShapeHandlers = <SCG extends ExtendableGenerics>({
488491 case 'message.new' :
489492 defaults . handleMessageNew ( {
490493 allowNewMessagesFromUnfilteredChannels,
491- sort,
492- filters,
493494 customHandler : onMessageNewHandler ,
494495 event,
496+ filters,
495497 lockChannelOrder,
496498 setChannels,
499+ sort,
497500 } ) ;
498501 break ;
499502 case 'notification.message_new' :
500503 defaults . handleNotificationMessageNew ( {
501504 allowNewMessagesFromUnfilteredChannels,
502- sort,
503- filters,
504505 customHandler : onMessageNew ,
505506 event,
507+ filters,
506508 lockChannelOrder,
507509 setChannels,
510+ sort,
508511 } ) ;
509512 break ;
510513 case 'notification.added_to_channel' :
511514 defaults . handleNotificationAddedToChannel ( {
512515 allowNewMessagesFromUnfilteredChannels,
513- sort,
514516 customHandler : onAddedToChannel ,
515517 event,
516518 lockChannelOrder,
517519 setChannels,
520+ sort,
518521 } ) ;
519522 break ;
520523 case 'notification.removed_from_channel' :
@@ -548,10 +551,10 @@ export const usePrepareShapeHandlers = <SCG extends ExtendableGenerics>({
548551 break ;
549552 case 'member.updated' :
550553 defaults . handleMemberUpdated ( {
551- sort,
552554 event,
553555 lockChannelOrder,
554556 setChannels,
557+ sort,
555558 } ) ;
556559 break ;
557560 default :
@@ -572,8 +575,8 @@ export const usePrepareShapeHandlers = <SCG extends ExtendableGenerics>({
572575 } , [ customHandleChannelListShape ] ) ;
573576
574577 return {
575- defaultFn ,
576- customFn ,
578+ customHandler : customFn ,
579+ defaultHandler : defaultFn ,
577580 } ;
578581} ;
579582
0 commit comments