import { useEffect, useMemo, useCallback } from 'react'; import { defineMessages, useIntl, FormattedMessage } from 'react-intl'; import { Helmet } from 'react-helmet'; import { Link } from 'react-router-dom'; import AddIcon from '@/material-icons/400-24px/add.svg?react'; import ListAltIcon from '@/material-icons/400-24px/list_alt.svg?react'; import MoreHorizIcon from '@/material-icons/400-24px/more_horiz.svg?react'; import SquigglyArrow from '@/svg-icons/squiggly_arrow.svg?react'; import { openModal } from 'mastodon/actions/modal'; import { Column } from 'mastodon/components/column'; import { ColumnHeader } from 'mastodon/components/column_header'; import { Dropdown } from 'mastodon/components/dropdown_menu'; import { Icon } from 'mastodon/components/icon'; import ScrollableList from 'mastodon/components/scrollable_list'; import { fetchAccountCollections, selectMyCollections, } from 'mastodon/reducers/slices/collections'; import { useAppSelector, useAppDispatch } from 'mastodon/store'; const messages = defineMessages({ heading: { id: 'column.collections', defaultMessage: 'My collections' }, create: { id: 'collections.create_collection', defaultMessage: 'Create collection', }, view: { id: 'collections.view_collection', defaultMessage: 'View collection', }, delete: { id: 'collections.delete_collection', defaultMessage: 'Delete collection', }, more: { id: 'status.more', defaultMessage: 'More' }, }); const ListItem: React.FC<{ id: string; name: string; }> = ({ id, name }) => { const dispatch = useAppDispatch(); const intl = useIntl(); const handleDeleteClick = useCallback(() => { dispatch( openModal({ modalType: 'CONFIRM_DELETE_LIST', modalProps: { listId: id, }, }), ); }, [dispatch, id]); const menu = useMemo( () => [ { text: intl.formatMessage(messages.view), to: `/collections/${id}` }, { text: intl.formatMessage(messages.delete), action: handleDeleteClick }, ], [intl, id, handleDeleteClick], ); return (
{name}
); }; export const Collections: React.FC<{ multiColumn?: boolean; }> = ({ multiColumn }) => { const dispatch = useAppDispatch(); const intl = useIntl(); const me = useAppSelector((state) => state.meta.get('me') as string); const { collections, status } = useAppSelector(selectMyCollections); useEffect(() => { void dispatch(fetchAccountCollections({ accountId: me })); }, [dispatch, me]); const emptyMessage = status === 'error' ? ( ) : ( <>
); return ( } /> {collections.map((item) => ( ))} {intl.formatMessage(messages.heading)} ); };