import { List as ImmutableList } from 'immutable'; import React, { useEffect } from 'react'; import { defineMessages, FormattedMessage, useIntl } from 'react-intl'; import { fetchAliases, removeFromAliases } from 'soapbox/actions/aliases'; import Icon from 'soapbox/components/icon'; import ScrollableList from 'soapbox/components/scrollable-list'; import { CardHeader, CardTitle, Column, HStack, Text } from 'soapbox/components/ui'; import { useAppDispatch, useAppSelector, useFeatures, useOwnAccount } from 'soapbox/hooks'; import Account from './components/account'; import Search from './components/search'; const messages = defineMessages({ heading: { id: 'column.aliases', defaultMessage: 'Account aliases' }, subheading_add_new: { id: 'column.aliases.subheading_add_new', defaultMessage: 'Add New Alias' }, create_error: { id: 'column.aliases.create_error', defaultMessage: 'Error creating alias' }, delete_error: { id: 'column.aliases.delete_error', defaultMessage: 'Error deleting alias' }, subheading_aliases: { id: 'column.aliases.subheading_aliases', defaultMessage: 'Current aliases' }, delete: { id: 'column.aliases.delete', defaultMessage: 'Delete' }, }); const Aliases = () => { const intl = useIntl(); const dispatch = useAppDispatch(); const features = useFeatures(); const account = useOwnAccount(); const aliases = useAppSelector((state) => { if (features.accountMoving) { return state.aliases.aliases.items; } else { return account!.pleroma.get('also_known_as'); } }) as ImmutableList; const searchAccountIds = useAppSelector((state) => state.aliases.suggestions.items); const loaded = useAppSelector((state) => state.aliases.suggestions.loaded); useEffect(() => { dispatch(fetchAliases); }, []); const handleFilterDelete: React.MouseEventHandler = e => { dispatch(removeFromAliases(e.currentTarget.dataset.value as string)); }; const emptyMessage = ; return ( { loaded && searchAccountIds.size === 0 ? (
) : (
{searchAccountIds.map(accountId => )}
) }
{aliases.map((alias, i) => (
{' '} {alias}
))}
); }; export default Aliases;