import React from 'react'; import { useOpenChannelList } from '@sendbird/uikit-chat-hooks'; import { OpenChannelPreview, PressBox } from '@sendbird/uikit-react-native-foundation'; import { NOOP } from '@sendbird/uikit-utils'; import StatusComposition from '../components/StatusComposition'; import { createOpenChannelListModule } from '../domain/openChannelList'; import type { OpenChannelListFragment, OpenChannelListModule, OpenChannelListProps, } from '../domain/openChannelList/types'; import { useLocalization, useSendbirdChat } from '../hooks/useContext'; const createOpenChannelListFragment = (initModule?: Partial): OpenChannelListFragment => { const OpenChannelListModule = createOpenChannelListModule(initModule); return ({ onPressCreateChannel, onPressChannel = NOOP, flatListProps, renderOpenChannelPreview, queryCreator }) => { const { sdk, currentUser } = useSendbirdChat(); const { STRINGS } = useLocalization(); const { openChannels, next, refresh, refreshing, loading, error } = useOpenChannelList(sdk, currentUser?.userId, { queryCreator, }); const _renderOpenChannelPreview: OpenChannelListProps['List']['renderOpenChannelPreview'] = (props) => { if (renderOpenChannelPreview) return renderOpenChannelPreview(props); return ( ); }; return ( } error={Boolean(error)} ErrorComponent={} > , contentContainerStyle: { flexGrow: 1 }, ...flatListProps, }} /> ); }; }; export default createOpenChannelListFragment;