2022-04-11 12:58:48 -07:00
|
|
|
import React from 'react';
|
|
|
|
import { defineMessages, FormattedMessage, useIntl } from 'react-intl';
|
|
|
|
|
2023-06-25 15:48:19 -07:00
|
|
|
import { useBlocks } from 'soapbox/api/hooks';
|
|
|
|
import Account from 'soapbox/components/account';
|
2022-11-15 08:00:49 -08:00
|
|
|
import ScrollableList from 'soapbox/components/scrollable-list';
|
2022-04-11 12:58:48 -07:00
|
|
|
import { Column, Spinner } from 'soapbox/components/ui';
|
|
|
|
|
|
|
|
const messages = defineMessages({
|
2023-06-08 06:00:49 -07:00
|
|
|
heading: { id: 'column.blocks', defaultMessage: 'Blocks' },
|
2022-04-11 12:58:48 -07:00
|
|
|
});
|
|
|
|
|
|
|
|
const Blocks: React.FC = () => {
|
|
|
|
const intl = useIntl();
|
|
|
|
|
2023-06-25 15:48:19 -07:00
|
|
|
const {
|
|
|
|
accounts,
|
|
|
|
hasNextPage,
|
|
|
|
fetchNextPage,
|
|
|
|
isLoading,
|
|
|
|
} = useBlocks();
|
2022-04-11 12:58:48 -07:00
|
|
|
|
2023-06-25 15:48:19 -07:00
|
|
|
if (isLoading) {
|
2022-04-11 12:58:48 -07:00
|
|
|
return (
|
|
|
|
<Column>
|
|
|
|
<Spinner />
|
|
|
|
</Column>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
const emptyMessage = <FormattedMessage id='empty_column.blocks' defaultMessage="You haven't blocked any users yet." />;
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Column label={intl.formatMessage(messages.heading)}>
|
|
|
|
<ScrollableList
|
|
|
|
scrollKey='blocks'
|
2023-06-25 15:48:19 -07:00
|
|
|
onLoadMore={fetchNextPage}
|
|
|
|
hasMore={hasNextPage}
|
2022-04-11 12:58:48 -07:00
|
|
|
emptyMessage={emptyMessage}
|
2023-06-08 06:00:49 -07:00
|
|
|
emptyMessageCard={false}
|
|
|
|
itemClassName='pb-4 last:pb-0'
|
2022-04-11 12:58:48 -07:00
|
|
|
>
|
2023-06-25 15:48:19 -07:00
|
|
|
{accounts.map((account) => (
|
|
|
|
<Account key={account.id} account={account} actionType='blocking' />
|
|
|
|
))}
|
2022-04-11 12:58:48 -07:00
|
|
|
</ScrollableList>
|
|
|
|
</Column>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2022-04-22 10:24:09 -07:00
|
|
|
export default Blocks;
|