import debounce from 'lodash/debounce'; import React from 'react'; import { defineMessages, useIntl, FormattedMessage } from 'react-intl'; import { fetchDomainBlocks, expandDomainBlocks } from 'soapbox/actions/domain-blocks'; import Domain from 'soapbox/components/domain'; import ScrollableList from 'soapbox/components/scrollable-list'; import { Column, Spinner } from 'soapbox/components/ui'; import { useAppDispatch, useAppSelector } from 'soapbox/hooks'; const messages = defineMessages({ heading: { id: 'column.domain_blocks', defaultMessage: 'Hidden domains' }, unblockDomain: { id: 'account.unblock_domain', defaultMessage: 'Unhide {domain}' }, }); const handleLoadMore = debounce((dispatch) => { dispatch(expandDomainBlocks()); }, 300, { leading: true }); const DomainBlocks: React.FC = () => { const dispatch = useAppDispatch(); const intl = useIntl(); const domains = useAppSelector((state) => state.domain_lists.blocks.items); const hasMore = useAppSelector((state) => !!state.domain_lists.blocks.next); React.useEffect(() => { dispatch(fetchDomainBlocks()); }, []); if (!domains) { return ( ); } const emptyMessage = ; return ( handleLoadMore(dispatch)} hasMore={hasMore} emptyMessage={emptyMessage} className='divide-y divide-gray-200 dark:divide-gray-800' > {domains.map((domain) => , )} ); }; export default DomainBlocks;