mirror of
https://github.com/glitch-soc/mastodon.git
synced 2026-03-29 03:00:33 +02:00
Remove minimum account limit on collections (#38082)
This commit is contained in:
@@ -82,10 +82,11 @@ const AccountFeatured: React.FC<{ multiColumn: boolean }> = ({
|
|||||||
const { collections, status } = useAppSelector((state) =>
|
const { collections, status } = useAppSelector((state) =>
|
||||||
selectAccountCollections(state, accountId ?? null),
|
selectAccountCollections(state, accountId ?? null),
|
||||||
);
|
);
|
||||||
const publicCollections = collections.filter(
|
const listedCollections = collections.filter(
|
||||||
// This filter only applies when viewing your own profile, where the endpoint
|
// Hide unlisted and empty collections to avoid confusion
|
||||||
// returns all collections, but we hide unlisted ones here to avoid confusion
|
// (Unlisted collections will only be part of the payload
|
||||||
(item) => item.discoverable,
|
// when viewing your own profile.)
|
||||||
|
(item) => item.discoverable && !!item.item_count,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (accountId === null) {
|
if (accountId === null) {
|
||||||
@@ -124,7 +125,7 @@ const AccountFeatured: React.FC<{ multiColumn: boolean }> = ({
|
|||||||
{accountId && (
|
{accountId && (
|
||||||
<AccountHeader accountId={accountId} hideTabs={forceEmptyState} />
|
<AccountHeader accountId={accountId} hideTabs={forceEmptyState} />
|
||||||
)}
|
)}
|
||||||
{publicCollections.length > 0 && status === 'idle' && (
|
{listedCollections.length > 0 && status === 'idle' && (
|
||||||
<>
|
<>
|
||||||
<h4 className='column-subheading'>
|
<h4 className='column-subheading'>
|
||||||
<FormattedMessage
|
<FormattedMessage
|
||||||
@@ -133,13 +134,13 @@ const AccountFeatured: React.FC<{ multiColumn: boolean }> = ({
|
|||||||
/>
|
/>
|
||||||
</h4>
|
</h4>
|
||||||
<ItemList>
|
<ItemList>
|
||||||
{publicCollections.map((item, index) => (
|
{listedCollections.map((item, index) => (
|
||||||
<CollectionListItem
|
<CollectionListItem
|
||||||
key={item.id}
|
key={item.id}
|
||||||
collection={item}
|
collection={item}
|
||||||
withoutBorder={index === publicCollections.length - 1}
|
withoutBorder={index === listedCollections.length - 1}
|
||||||
positionInList={index + 1}
|
positionInList={index + 1}
|
||||||
listSize={publicCollections.length}
|
listSize={listedCollections.length}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
</ItemList>
|
</ItemList>
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ import { Account } from 'mastodon/components/account';
|
|||||||
import { Avatar } from 'mastodon/components/avatar';
|
import { Avatar } from 'mastodon/components/avatar';
|
||||||
import { Badge } from 'mastodon/components/badge';
|
import { Badge } from 'mastodon/components/badge';
|
||||||
import { Button } from 'mastodon/components/button';
|
import { Button } from 'mastodon/components/button';
|
||||||
import { Callout } from 'mastodon/components/callout';
|
|
||||||
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 { FormStack, Combobox } from 'mastodon/components/form_fields';
|
import { FormStack, Combobox } from 'mastodon/components/form_fields';
|
||||||
@@ -40,7 +39,6 @@ import { getCollectionEditorState } from './state';
|
|||||||
import classes from './styles.module.scss';
|
import classes from './styles.module.scss';
|
||||||
import { WizardStepHeader } from './wizard_step_header';
|
import { WizardStepHeader } from './wizard_step_header';
|
||||||
|
|
||||||
const MIN_ACCOUNT_COUNT = 1;
|
|
||||||
const MAX_ACCOUNT_COUNT = 25;
|
const MAX_ACCOUNT_COUNT = 25;
|
||||||
|
|
||||||
function isOlderThanAWeek(date?: string): boolean {
|
function isOlderThanAWeek(date?: string): boolean {
|
||||||
@@ -164,9 +162,6 @@ export const CollectionAccounts: React.FC<{
|
|||||||
);
|
);
|
||||||
|
|
||||||
const hasMaxAccounts = accountIds.length === MAX_ACCOUNT_COUNT;
|
const hasMaxAccounts = accountIds.length === MAX_ACCOUNT_COUNT;
|
||||||
const hasMinAccounts = accountIds.length === MIN_ACCOUNT_COUNT;
|
|
||||||
const hasTooFewAccounts = accountIds.length < MIN_ACCOUNT_COUNT;
|
|
||||||
const canSubmit = !hasTooFewAccounts;
|
|
||||||
|
|
||||||
const {
|
const {
|
||||||
accountIds: suggestedAccountIds,
|
accountIds: suggestedAccountIds,
|
||||||
@@ -319,17 +314,13 @@ export const CollectionAccounts: React.FC<{
|
|||||||
(e: React.FormEvent) => {
|
(e: React.FormEvent) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
if (!canSubmit) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!id) {
|
if (!id) {
|
||||||
history.push(`/collections/new/details`, {
|
history.push(`/collections/new/details`, {
|
||||||
account_ids: accountIds,
|
account_ids: accountIds,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[canSubmit, id, history, accountIds],
|
[id, history, accountIds],
|
||||||
);
|
);
|
||||||
|
|
||||||
const inputId = useId();
|
const inputId = useId();
|
||||||
@@ -384,16 +375,6 @@ export const CollectionAccounts: React.FC<{
|
|||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{hasMinAccounts && (
|
|
||||||
<Callout>
|
|
||||||
<FormattedMessage
|
|
||||||
id='collections.hints.can_not_remove_more_accounts'
|
|
||||||
defaultMessage='Collections must contain at least {count, plural, one {# account} other {# accounts}}. Removing more accounts is not possible.'
|
|
||||||
values={{ count: MIN_ACCOUNT_COUNT }}
|
|
||||||
/>
|
|
||||||
</Callout>
|
|
||||||
)}
|
|
||||||
|
|
||||||
<Scrollable className={classes.scrollableWrapper}>
|
<Scrollable className={classes.scrollableWrapper}>
|
||||||
<ItemList
|
<ItemList
|
||||||
className={classes.scrollableInner}
|
className={classes.scrollableInner}
|
||||||
@@ -425,7 +406,7 @@ export const CollectionAccounts: React.FC<{
|
|||||||
>
|
>
|
||||||
<AddedAccountItem
|
<AddedAccountItem
|
||||||
accountId={accountId}
|
accountId={accountId}
|
||||||
isRemovable={!isEditMode || !hasMinAccounts}
|
isRemovable={!isEditMode}
|
||||||
onRemove={handleRemoveAccountItem}
|
onRemove={handleRemoveAccountItem}
|
||||||
/>
|
/>
|
||||||
</Article>
|
</Article>
|
||||||
@@ -435,39 +416,25 @@ export const CollectionAccounts: React.FC<{
|
|||||||
</FormStack>
|
</FormStack>
|
||||||
{!isEditMode && (
|
{!isEditMode && (
|
||||||
<div className={classes.stickyFooter}>
|
<div className={classes.stickyFooter}>
|
||||||
{hasTooFewAccounts ? (
|
<div className={classes.actionWrapper}>
|
||||||
<Callout icon={false} className={classes.submitDisabledCallout}>
|
<FormattedMessage
|
||||||
<FormattedMessage
|
id='collections.hints.accounts_counter'
|
||||||
id='collections.hints.add_more_accounts'
|
defaultMessage='{count} / {max} accounts'
|
||||||
defaultMessage='Add at least {count, plural, one {# account} other {# accounts}} to continue'
|
values={{ count: accountIds.length, max: MAX_ACCOUNT_COUNT }}
|
||||||
values={{ count: MIN_ACCOUNT_COUNT }}
|
>
|
||||||
/>
|
{(text) => <div className={classes.itemCountReadout}>{text}</div>}
|
||||||
</Callout>
|
</FormattedMessage>
|
||||||
) : (
|
<Button type='submit'>
|
||||||
<div className={classes.actionWrapper}>
|
{id ? (
|
||||||
<FormattedMessage
|
<FormattedMessage id='lists.save' defaultMessage='Save' />
|
||||||
id='collections.hints.accounts_counter'
|
) : (
|
||||||
defaultMessage='{count} / {max} accounts'
|
<FormattedMessage
|
||||||
values={{ count: accountIds.length, max: MAX_ACCOUNT_COUNT }}
|
id='collections.continue'
|
||||||
>
|
defaultMessage='Continue'
|
||||||
{(text) => (
|
/>
|
||||||
<div className={classes.itemCountReadout}>{text}</div>
|
|
||||||
)}
|
|
||||||
</FormattedMessage>
|
|
||||||
{canSubmit && (
|
|
||||||
<Button type='submit'>
|
|
||||||
{id ? (
|
|
||||||
<FormattedMessage id='lists.save' defaultMessage='Save' />
|
|
||||||
) : (
|
|
||||||
<FormattedMessage
|
|
||||||
id='collections.continue'
|
|
||||||
defaultMessage='Continue'
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
</Button>
|
|
||||||
)}
|
)}
|
||||||
</div>
|
</Button>
|
||||||
)}
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</form>
|
</form>
|
||||||
|
|||||||
@@ -337,8 +337,6 @@
|
|||||||
"collections.edit_details": "Edit details",
|
"collections.edit_details": "Edit details",
|
||||||
"collections.error_loading_collections": "There was an error when trying to load your collections.",
|
"collections.error_loading_collections": "There was an error when trying to load your collections.",
|
||||||
"collections.hints.accounts_counter": "{count} / {max} accounts",
|
"collections.hints.accounts_counter": "{count} / {max} accounts",
|
||||||
"collections.hints.add_more_accounts": "Add at least {count, plural, one {# account} other {# accounts}} to continue",
|
|
||||||
"collections.hints.can_not_remove_more_accounts": "Collections must contain at least {count, plural, one {# account} other {# accounts}}. Removing more accounts is not possible.",
|
|
||||||
"collections.last_updated_at": "Last updated: {date}",
|
"collections.last_updated_at": "Last updated: {date}",
|
||||||
"collections.manage_accounts": "Manage accounts",
|
"collections.manage_accounts": "Manage accounts",
|
||||||
"collections.mark_as_sensitive": "Mark as sensitive",
|
"collections.mark_as_sensitive": "Mark as sensitive",
|
||||||
|
|||||||
Reference in New Issue
Block a user