11import React from 'react' ;
22
3- import { useGroupChannelList } from '@sendbird/uikit-chat-hooks' ;
4- import { PASS , useAppState , useFreshCallback } from '@sendbird/uikit-utils' ;
3+ import { GroupChannelCollection , GroupChannelFilter } from '@sendbird/chat/groupChannel' ;
4+ import { useGroupChannelList } from '@sendbird/uikit-tools' ;
5+ import { PASS , SendbirdChatSDK , confirmAndMarkAsDelivered , useAppState , useFreshCallback } from '@sendbird/uikit-utils' ;
56
67import StatusComposition from '../components/StatusComposition' ;
78import GroupChannelPreviewContainer from '../containers/GroupChannelPreviewContainer' ;
@@ -18,16 +19,17 @@ const createGroupChannelListFragment = (initModule?: Partial<GroupChannelListMod
1819 return ( {
1920 onPressChannel,
2021 onPressCreateChannel,
21- collectionCreator,
2222 renderGroupChannelPreview,
2323 skipTypeSelection = false ,
2424 flatListProps = { } ,
2525 menuItemCreator = PASS ,
26+ channelListQueryParams,
27+ collectionCreator,
2628 } ) => {
27- const { sdk, currentUser , sbOptions, markAsDeliveredWithChannel } = useSendbirdChat ( ) ;
28- const { groupChannels, next , loading } = useGroupChannelList ( sdk , currentUser ?. userId , {
29- collectionCreator,
30- enableCollectionWithoutLocalCache : true ,
29+ const { sdk, sbOptions, markAsDeliveredWithChannel } = useSendbirdChat ( ) ;
30+ const { groupChannels, loadMore , initialized } = useGroupChannelList ( sdk , {
31+ collectionCreator : getCollectionCreator ( sdk , channelListQueryParams , collectionCreator ) ,
32+ markAsDelivered : confirmAndMarkAsDelivered ,
3133 } ) ;
3234
3335 if ( sbOptions . appInfo . deliveryReceiptEnabled ) {
@@ -49,13 +51,13 @@ const createGroupChannelListFragment = (initModule?: Partial<GroupChannelListMod
4951 return (
5052 < GroupChannelListModule . Provider >
5153 < GroupChannelListModule . Header />
52- < StatusComposition loading = { loading } LoadingComponent = { < GroupChannelListModule . StatusLoading /> } >
54+ < StatusComposition loading = { ! initialized } LoadingComponent = { < GroupChannelListModule . StatusLoading /> } >
5355 < GroupChannelListModule . List
5456 onPressChannel = { onPressChannel }
5557 menuItemCreator = { menuItemCreator }
5658 renderGroupChannelPreview = { _renderGroupChannelPreview }
5759 groupChannels = { groupChannels }
58- onLoadNext = { next }
60+ onLoadNext = { loadMore }
5961 flatListProps = { {
6062 ListEmptyComponent : < GroupChannelListModule . StatusEmpty /> ,
6163 contentContainerStyle : { flexGrow : 1 } ,
@@ -72,4 +74,20 @@ const createGroupChannelListFragment = (initModule?: Partial<GroupChannelListMod
7274 } ;
7375} ;
7476
77+ function getCollectionCreator (
78+ sdk : SendbirdChatSDK ,
79+ channelListQueryParams ?: GroupChannelListProps [ 'Fragment' ] [ 'channelListQueryParams' ] ,
80+ deprecatedCreatorProp ?: ( ) => GroupChannelCollection ,
81+ ) {
82+ if ( ! channelListQueryParams && deprecatedCreatorProp ) return deprecatedCreatorProp ;
83+
84+ return ( defaultParams : GroupChannelListProps [ 'Fragment' ] [ 'channelListQueryParams' ] ) => {
85+ const params = { ...defaultParams , ...channelListQueryParams } ;
86+ return sdk . groupChannel . createGroupChannelCollection ( {
87+ ...params ,
88+ filter : new GroupChannelFilter ( params ) ,
89+ } ) ;
90+ } ;
91+ }
92+
7593export default createGroupChannelListFragment ;
0 commit comments