import { useEffect } from 'react'; import { FormattedMessage } from 'react-intl'; import { useAccount } from '@/mastodon/hooks/useAccount'; import { EmptyState } from 'mastodon/components/empty_state'; import { LoadingIndicator } from 'mastodon/components/loading_indicator'; import { ItemList } from 'mastodon/components/scrollable_list/components'; import { useAccountId } from 'mastodon/hooks/useAccountId'; import { fetchCollectionsFeaturingAccount, selectAccountCollections, } from 'mastodon/reducers/slices/collections'; import { useAppSelector, useAppDispatch } from 'mastodon/store'; import { CollectionListItem } from '../components/collection_list_item'; import classes from '../styles.module.scss'; import { CollectionListError } from './created_by_account'; function useCollectionsFeaturing(accountId: string | null | undefined) { const dispatch = useAppDispatch(); useEffect(() => { if (accountId) { void dispatch(fetchCollectionsFeaturingAccount({ accountId })); } }, [dispatch, accountId]); return useAppSelector((state) => selectAccountCollections(state, accountId, 'featuring'), ); } export const CollectionsFeaturingYou: React.FC = () => { const accountId = useAccountId(); const account = useAccount(accountId); const { collections, status } = useCollectionsFeaturing(accountId); if (status === 'error' || !accountId) { return ; } if (status === 'loading') { return ; } if (collections.length === 0) { if (account?.discoverable) { return ( } /> ); } else { return (
( {chunks} ), }} /> } /> ); } } return ( <>

{collections.map((item, index) => ( ))} ); };