Change "My collections" path to /@username/collections (#38630)

This commit is contained in:
diondiondion authored and GitHub committed 2026-04-09 15:31:49 +00:00
1 parent ef4a583f54
commit d6c0b93c85
8 files changed
+63 -33

No files matched your search

@@ -10,11 +10,14 @@ import CollectionsFilledIcon from '@/material-icons/400-24px/category-fill.svg?r
import SquigglyArrow from '@/svg-icons/squiggly_arrow.svg?react';
import { Column } from 'mastodon/components/column';
import { ColumnHeader } from 'mastodon/components/column_header';
import { DisplayNameSimple } from 'mastodon/components/display_name/simple';
import { Icon } from 'mastodon/components/icon';
import {
ItemList,
Scrollable,
} from 'mastodon/components/scrollable_list/components';
import { useAccount } from 'mastodon/hooks/useAccount';
import { useAccountId, useCurrentAccountId } from 'mastodon/hooks/useAccountId';
import {
fetchAccountCollections,
selectAccountCollections,
@@ -25,7 +28,11 @@ import { CollectionListItem } from './components/collection_list_item';
import { messages as editorMessages } from './editor';
const messages = defineMessages({
heading: { id: 'column.collections', defaultMessage: 'My collections' },
headingMe: { id: 'column.my_collections', defaultMessage: 'My collections' },
headingOther: {
id: 'column.other_collections',
defaultMessage: 'Collections by {name}',
},
});
export const Collections: React.FC<{
@@ -33,17 +40,22 @@ export const Collections: React.FC<{
}> = ({ multiColumn }) => {
const dispatch = useAppDispatch();
const intl = useIntl();
const me = useAppSelector((state) => state.meta.get('me') as string);
const me = useCurrentAccountId();
const accountId = useAccountId();
const account = useAccount(accountId);
const { collections, status } = useAppSelector((state) =>
selectAccountCollections(state, me),
selectAccountCollections(state, accountId),
);
useEffect(() => {
void dispatch(fetchAccountCollections({ accountId: me }));
}, [dispatch, me]);
if (accountId) {
void dispatch(fetchAccountCollections({ accountId }));
}
}, [dispatch, accountId]);
const emptyMessage =
status === 'error' ? (
status === 'error' || !accountId ? (
<FormattedMessage
id='collections.error_loading_collections'
defaultMessage='There was an error when trying to load your collections.'
@@ -67,25 +79,36 @@ export const Collections: React.FC<{
</>
);
const isOwnCollection = accountId === me;
const titleMessage = isOwnCollection
? messages.headingMe
: messages.headingOther;
const pageTitle = intl.formatMessage(titleMessage, {
name: account?.get('display_name'),
});
const pageTitleHtml = intl.formatMessage(titleMessage, {
name: <DisplayNameSimple account={account} />,
});
return (
<Column
bindToDocument={!multiColumn}
label={intl.formatMessage(messages.heading)}
>
<Column bindToDocument={!multiColumn} label={pageTitle}>
<ColumnHeader
title={intl.formatMessage(messages.heading)}
title={pageTitleHtml}
icon='collections'
iconComponent={CollectionsFilledIcon}
multiColumn={multiColumn}
extraButton={
<Link
to='/collections/new'
className='column-header__button'
title={intl.formatMessage(editorMessages.create)}
aria-label={intl.formatMessage(editorMessages.create)}
>
<Icon id='plus' icon={AddIcon} />
</Link>
isOwnCollection && (
<Link
to='/collections/new'
className='column-header__button'
title={intl.formatMessage(editorMessages.create)}
aria-label={intl.formatMessage(editorMessages.create)}
>
<Icon id='plus' icon={AddIcon} />
</Link>
)
}
/>
@@ -105,7 +128,7 @@ export const Collections: React.FC<{
</Scrollable>
<Helmet>
<title>{intl.formatMessage(messages.heading)}</title>
<title>{pageTitle}</title>
<meta name='robots' content='noindex' />
</Helmet>
</Column>