Remove frontend check for collections feature flag (#39215)

This commit is contained in:
diondiondion 2026-05-29 15:07:00 +02:00 committed by GitHub
parent a86f3a4000
commit 7fba458d92
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 98 additions and 146 deletions

View File

@ -9,7 +9,6 @@ import { Button } from '@/mastodon/components/button';
import { DisplayName } from '@/mastodon/components/display_name'; import { DisplayName } from '@/mastodon/components/display_name';
import { EmptyState } from '@/mastodon/components/empty_state'; import { EmptyState } from '@/mastodon/components/empty_state';
import { LimitedAccountHint } from '@/mastodon/components/limited_account_hint'; import { LimitedAccountHint } from '@/mastodon/components/limited_account_hint';
import { areCollectionsEnabled } from '@/mastodon/features/collections/utils';
import { useAccount } from '@/mastodon/hooks/useAccount'; import { useAccount } from '@/mastodon/hooks/useAccount';
import { useCurrentAccountId } from '@/mastodon/hooks/useAccountId'; import { useCurrentAccountId } from '@/mastodon/hooks/useAccountId';
import { useAppDispatch } from '@/mastodon/store'; import { useAppDispatch } from '@/mastodon/store';
@ -50,56 +49,39 @@ export const EmptyMessage: React.FC<EmptyMessageProps> = ({
let title: React.ReactNode = null; let title: React.ReactNode = null;
let message: React.ReactNode = null; let message: React.ReactNode = null;
const hasCollections = areCollectionsEnabled();
if (me === accountId) { if (me === accountId) {
if (hasCollections) { // Return only here to insert the "Create a collection" button as the action for the empty state.
// Return only here to insert the "Create a collection" button as the action for the empty state. return (
return ( <EmptyState
<EmptyState title={
title={ <FormattedMessage
id='empty_column.account_featured_self.showcase_accounts'
defaultMessage='Showcase your favorite accounts'
/>
}
message={
<FormattedMessage
id='empty_column.account_featured_self.showcase_accounts_desc'
defaultMessage='Collections are curated lists of accounts to help others discover more of the Fediverse.'
/>
}
>
{!withoutAddCollectionButton && (
<Link to='/collections/new' className='button'>
<FormattedMessage <FormattedMessage
id='empty_column.account_featured_self.showcase_accounts' id='empty_column.account_featured_self.no_collections_button'
defaultMessage='Showcase your favorite accounts' defaultMessage='Create a collection'
/> />
} </Link>
message={ )}
<FormattedMessage <Button secondary onClick={confirmHideFeaturedTab}>
id='empty_column.account_featured_self.showcase_accounts_desc' <FormattedMessage
defaultMessage='Collections are curated lists of accounts to help others discover more of the Fediverse.' id='empty_column.account_featured_self.no_collections_hide_tab'
/> defaultMessage='Hide this tab instead'
} />
> </Button>
{!withoutAddCollectionButton && ( </EmptyState>
<Link to='/collections/new' className='button'> );
<FormattedMessage
id='empty_column.account_featured_self.no_collections_button'
defaultMessage='Create a collection'
/>
</Link>
)}
<Button secondary onClick={confirmHideFeaturedTab}>
<FormattedMessage
id='empty_column.account_featured_self.no_collections_hide_tab'
defaultMessage='Hide this tab instead'
/>
</Button>
</EmptyState>
);
} else {
title = (
<FormattedMessage
id='empty_column.account_featured_self.pre_collections'
defaultMessage='Stay tuned for Collections'
/>
);
message = (
<FormattedMessage
id='empty_column.account_featured_self.pre_collections_desc'
defaultMessage='Collections (coming in Mastodon 4.6) allow you to create your own curated lists of accounts to recommend to others.'
/>
);
}
} else if (suspended) { } else if (suspended) {
title = ( title = (
<FormattedMessage <FormattedMessage

View File

@ -30,13 +30,10 @@ import AddIcon from '@/material-icons/400-24px/add.svg?react';
import { CollectionListItem } from '../collections/components/collection_list_item'; import { CollectionListItem } from '../collections/components/collection_list_item';
import { useCollectionsCreatedBy } from '../collections/overview/created_by_you'; import { useCollectionsCreatedBy } from '../collections/overview/created_by_you';
import { areCollectionsEnabled } from '../collections/utils';
import { EmptyMessage } from './components/empty_message'; import { EmptyMessage } from './components/empty_message';
import { Subheading, SubheadingLink } from './components/subheading'; import { Subheading, SubheadingLink } from './components/subheading';
const collectionsEnabled = areCollectionsEnabled();
const AccountFeatured: React.FC<{ multiColumn: boolean }> = ({ const AccountFeatured: React.FC<{ multiColumn: boolean }> = ({
multiColumn, multiColumn,
}) => { }) => {
@ -98,14 +95,11 @@ const AccountFeatured: React.FC<{ multiColumn: boolean }> = ({
); );
const hasCollections = const hasCollections =
collectionsEnabled && collectionsLoadStatus === 'idle' && listedCollections.length > 0;
collectionsLoadStatus === 'idle' &&
listedCollections.length > 0;
const hasFeaturedAccounts = !featuredAccountIds.isEmpty(); const hasFeaturedAccounts = !featuredAccountIds.isEmpty();
const isLoading = const isLoading = !accountId || collectionsLoadStatus !== 'idle';
!accountId || (collectionsEnabled && collectionsLoadStatus !== 'idle');
if (accountId === null) { if (accountId === null) {
return <BundleColumnError multiColumn={multiColumn} errorType='routing' />; return <BundleColumnError multiColumn={multiColumn} errorType='routing' />;
@ -165,57 +159,53 @@ const AccountFeatured: React.FC<{ multiColumn: boolean }> = ({
</ItemList> </ItemList>
</> </>
)} )}
{collectionsEnabled && ( <Subheading as='header'>
<> <h2>
<Subheading as='header'> <FormattedMessage
<h2> id='account.featured.collections'
<FormattedMessage defaultMessage='Collections'
id='account.featured.collections' />
defaultMessage='Collections' </h2>
/> {accountId === me && (
</h2> <SubheadingLink to='/collections/new' icon={AddIcon}>
{accountId === me && ( <FormattedMessage
<SubheadingLink to='/collections/new' icon={AddIcon}> id='account.featured.new_collection'
<FormattedMessage defaultMessage='New collection'
id='account.featured.new_collection'
defaultMessage='New collection'
/>
</SubheadingLink>
)}
</Subheading>
{hasCollections ? (
<ItemList>
<TruncatedListItems
visibleItems={listedCollections}
truncatedItems={unlistedCollections}
toggleButton={{
title: (
<FormattedMessage
id='collections.unlisted_collections_with_count'
defaultMessage='Unlisted collections ({count})'
values={{ count: unlistedCollections.length }}
/>
),
subtitle: (
<FormattedMessage
id='collections.unlisted_collections_description'
defaultMessage='These dont appear on your profile to others. Anyone with the link can discover them.'
/>
),
}}
renderListItem={renderListItem}
/>
</ItemList>
) : (
<EmptyMessage
withoutAddCollectionButton
blockedBy={blockedBy}
hidden={hidden}
suspended={suspended}
accountId={accountId}
/> />
)} </SubheadingLink>
</> )}
</Subheading>
{hasCollections ? (
<ItemList>
<TruncatedListItems
visibleItems={listedCollections}
truncatedItems={unlistedCollections}
toggleButton={{
title: (
<FormattedMessage
id='collections.unlisted_collections_with_count'
defaultMessage='Unlisted collections ({count})'
values={{ count: unlistedCollections.length }}
/>
),
subtitle: (
<FormattedMessage
id='collections.unlisted_collections_description'
defaultMessage='These dont appear on your profile to others. Anyone with the link can discover them.'
/>
),
}}
renderListItem={renderListItem}
/>
</ItemList>
) : (
<EmptyMessage
withoutAddCollectionButton
blockedBy={blockedBy}
hidden={hidden}
suspended={suspended}
accountId={accountId}
/>
)} )}
<RemoteHint accountId={accountId} /> <RemoteHint accountId={accountId} />
</Scrollable> </Scrollable>

View File

@ -23,7 +23,6 @@ import {
userCollectionLimit, userCollectionLimit,
} from '../editor'; } from '../editor';
import classes from '../styles.module.scss'; import classes from '../styles.module.scss';
import { areCollectionsEnabled } from '../utils';
const CreateButton: React.FC = () => ( const CreateButton: React.FC = () => (
<Link to='/collections/new' className='button button--compact'> <Link to='/collections/new' className='button button--compact'>
@ -49,7 +48,7 @@ export function useCollectionsCreatedBy(accountId: string | null | undefined) {
const dispatch = useAppDispatch(); const dispatch = useAppDispatch();
useEffect(() => { useEffect(() => {
if (accountId && areCollectionsEnabled()) { if (accountId) {
void dispatch(fetchCollectionsCreatedByAccount({ accountId })); void dispatch(fetchCollectionsCreatedByAccount({ accountId }));
} }
}, [dispatch, accountId]); }, [dispatch, accountId]);

View File

@ -15,7 +15,6 @@ import { useAppSelector, useAppDispatch } from 'mastodon/store';
import { CollectionListItem } from '../components/collection_list_item'; import { CollectionListItem } from '../components/collection_list_item';
import classes from '../styles.module.scss'; import classes from '../styles.module.scss';
import { areCollectionsEnabled } from '../utils';
import { CollectionListError } from './created_by_you'; import { CollectionListError } from './created_by_you';
@ -23,7 +22,7 @@ function useCollectionsFeaturing(accountId: string | null | undefined) {
const dispatch = useAppDispatch(); const dispatch = useAppDispatch();
useEffect(() => { useEffect(() => {
if (accountId && areCollectionsEnabled()) { if (accountId) {
void dispatch(fetchCollectionsFeaturingAccount({ accountId })); void dispatch(fetchCollectionsFeaturingAccount({ accountId }));
} }
}, [dispatch, accountId]); }, [dispatch, accountId]);

View File

@ -1,10 +1,5 @@
import type { ApiAccountJSON } from '@/mastodon/api_types/accounts'; import type { ApiAccountJSON } from '@/mastodon/api_types/accounts';
import type { Account } from '@/mastodon/models/account'; import type { Account } from '@/mastodon/models/account';
import { isServerFeatureEnabled } from '@/mastodon/utils/environment';
export function areCollectionsEnabled() {
return isServerFeatureEnabled('collections');
}
export const getCollectionPath = (id: string) => `/collections/${id}`; export const getCollectionPath = (id: string) => `/collections/${id}`;

View File

@ -51,7 +51,6 @@ import { selectUnreadNotificationGroupsCount } from 'mastodon/selectors/notifica
import { useAppSelector, useAppDispatch } from 'mastodon/store'; import { useAppSelector, useAppDispatch } from 'mastodon/store';
import { AnnualReportNavItem } from '../annual_report/nav_item'; import { AnnualReportNavItem } from '../annual_report/nav_item';
import { areCollectionsEnabled } from '../collections/utils';
import { DisabledAccountBanner } from './components/disabled_account_banner'; import { DisabledAccountBanner } from './components/disabled_account_banner';
import { FollowedTagsPanel } from './components/followed_tags_panel'; import { FollowedTagsPanel } from './components/followed_tags_panel';
@ -361,18 +360,16 @@ export const NavigationPanel: React.FC<{ multiColumn?: boolean }> = ({
text={intl.formatMessage(messages.bookmarks)} text={intl.formatMessage(messages.bookmarks)}
/> />
</li> </li>
{areCollectionsEnabled() && ( <li>
<li> <ColumnLink
<ColumnLink transparent
transparent to={`/@${account?.acct}/collections`}
to={`/@${account?.acct}/collections`} icon='collections'
icon='collections' iconComponent={CollectionsIcon}
iconComponent={CollectionsIcon} activeIconComponent={CollectionsActiveIcon}
activeIconComponent={CollectionsActiveIcon} text={intl.formatMessage(messages.collections)}
text={intl.formatMessage(messages.collections)} />
/> </li>
</li>
)}
<li> <li>
<ColumnLink <ColumnLink
transparent transparent

View File

@ -17,7 +17,6 @@ import { blockAccount } from 'mastodon/actions/accounts';
import { closeModal } from 'mastodon/actions/modal'; import { closeModal } from 'mastodon/actions/modal';
import { Button } from 'mastodon/components/button'; import { Button } from 'mastodon/components/button';
import { Icon } from 'mastodon/components/icon'; import { Icon } from 'mastodon/components/icon';
import { areCollectionsEnabled } from '../../collections/utils';
export const BlockModal = ({ accountId, acct }) => { export const BlockModal = ({ accountId, acct }) => {
const dispatch = useDispatch(); const dispatch = useDispatch();
@ -73,12 +72,10 @@ export const BlockModal = ({ accountId, acct }) => {
<div><FormattedMessage id='block_modal.they_cant_mention' defaultMessage="You can't mention, follow, or quote each other." /></div> <div><FormattedMessage id='block_modal.they_cant_mention' defaultMessage="You can't mention, follow, or quote each other." /></div>
</li> </li>
{areCollectionsEnabled() && <li>
<li> <div className='safety-action-modal__bullet-points__icon'><Icon icon={CollectionsIcon} /></div>
<div className='safety-action-modal__bullet-points__icon'><Icon icon={CollectionsIcon} /></div> <div><FormattedMessage id='block_modal.no_collections' defaultMessage="Neither of you can add each other to collections. You'll be automatically removed from each others' existing collections, if applicable." /></div>
<div><FormattedMessage id='block_modal.no_collections' defaultMessage="Neither of you can add each other to collections. You'll be automatically removed from each others' existing collections, if applicable." /></div> </li>
</li>
}
</ul> </ul>
</div> </div>

View File

@ -93,7 +93,6 @@ import { CustomHomepage } from 'mastodon/features/custom_homepage';
// Dummy import, to make sure that <Status /> ends up in the application bundle. // Dummy import, to make sure that <Status /> ends up in the application bundle.
// Without this it ends up in ~8 very commonly used bundles. // Without this it ends up in ~8 very commonly used bundles.
import '../../components/status'; import '../../components/status';
import { areCollectionsEnabled } from '../collections/utils';
import { getNavigationSkipLinkId, SkipLinks } from './components/skip_links'; import { getNavigationSkipLinkId, SkipLinks } from './components/skip_links';
const messages = defineMessages({ const messages = defineMessages({
@ -235,13 +234,9 @@ class SwitchingColumnsArea extends PureComponent {
<WrappedRoute path={['/@:acct', '/accounts/:id']} exact component={AccountTimeline} content={children} /> <WrappedRoute path={['/@:acct', '/accounts/:id']} exact component={AccountTimeline} content={children} />
<WrappedRoute path={['/@:acct/featured', '/accounts/:id/featured']} component={AccountFeatured} content={children} /> <WrappedRoute path={['/@:acct/featured', '/accounts/:id/featured']} component={AccountFeatured} content={children} />
{areCollectionsEnabled() && <WrappedRoute path={['/@:acct/collections']} component={Collections} content={children} key='collections-list' />
[ <WrappedRoute path={['/collections/new', '/collections/:id/edit']} component={CollectionsEditor} content={children} key='collections-editor' />
<WrappedRoute path={['/@:acct/collections']} component={Collections} content={children} key='collections-list' />, <WrappedRoute path='/collections/:id' component={CollectionDetail} content={children} key='collections-detail' />
<WrappedRoute path={['/collections/new', '/collections/:id/edit']} component={CollectionsEditor} content={children} key='collections-editor' />,
<WrappedRoute path='/collections/:id' component={CollectionDetail} content={children} key='collections-detail' />,
]
}
<WrappedRoute path='/@:acct/tagged/:tagged?' exact component={AccountTimeline} content={children} /> <WrappedRoute path='/@:acct/tagged/:tagged?' exact component={AccountTimeline} content={children} />
<WrappedRoute path={['/@:acct/with_replies', '/accounts/:id/with_replies']} component={AccountTimeline} content={children} componentParams={{ withReplies: true }} /> <WrappedRoute path={['/@:acct/with_replies', '/accounts/:id/with_replies']} component={AccountTimeline} content={children} componentParams={{ withReplies: true }} />
<WrappedRoute path={['/accounts/:id/followers', '/users/:acct/followers', '/@:acct/followers']} component={Followers} content={children} /> <WrappedRoute path={['/accounts/:id/followers', '/users/:acct/followers', '/@:acct/followers']} component={Followers} content={children} />

View File

@ -637,8 +637,6 @@
"empty_column.account_featured.other": "{acct} has not featured anything yet.", "empty_column.account_featured.other": "{acct} has not featured anything yet.",
"empty_column.account_featured_self.no_collections_button": "Create a collection", "empty_column.account_featured_self.no_collections_button": "Create a collection",
"empty_column.account_featured_self.no_collections_hide_tab": "Hide this tab instead", "empty_column.account_featured_self.no_collections_hide_tab": "Hide this tab instead",
"empty_column.account_featured_self.pre_collections": "Stay tuned for Collections",
"empty_column.account_featured_self.pre_collections_desc": "Collections (coming in Mastodon 4.6) allow you to create your own curated lists of accounts to recommend to others.",
"empty_column.account_featured_self.showcase_accounts": "Showcase your favorite accounts", "empty_column.account_featured_self.showcase_accounts": "Showcase your favorite accounts",
"empty_column.account_featured_self.showcase_accounts_desc": "Collections are curated lists of accounts to help others discover more of the Fediverse.", "empty_column.account_featured_self.showcase_accounts_desc": "Collections are curated lists of accounts to help others discover more of the Fediverse.",
"empty_column.account_featured_unknown.other": "This account hasnt featured anything yet.", "empty_column.account_featured_unknown.other": "This account hasnt featured anything yet.",

View File

@ -12,7 +12,7 @@ export function isProduction() {
else return import.meta.env.PROD; else return import.meta.env.PROD;
} }
export type ServerFeatures = 'fasp' | 'collections'; export type ServerFeatures = 'fasp';
export function isServerFeatureEnabled(feature: ServerFeatures) { export function isServerFeatureEnabled(feature: ServerFeatures) {
return initialState?.features.includes(feature) ?? false; return initialState?.features.includes(feature) ?? false;