mirror of
https://github.com/mastodon/mastodon.git
synced 2026-03-21 18:05:23 -05:00
Only suggest discoverable accounts in collection account editor (#37920)
This commit is contained in:
parent
7eb4b907eb
commit
39ff07bc89
|
|
@ -12,6 +12,26 @@ export interface ApiAccountRoleJSON {
|
|||
name: string;
|
||||
}
|
||||
|
||||
type ApiFeaturePolicy =
|
||||
| 'public'
|
||||
| 'followers'
|
||||
| 'following'
|
||||
| 'disabled'
|
||||
| 'unsupported_policy';
|
||||
|
||||
type ApiUserFeaturePolicy =
|
||||
| 'automatic'
|
||||
| 'manual'
|
||||
| 'denied'
|
||||
| 'missing'
|
||||
| 'unknown';
|
||||
|
||||
interface ApiFeaturePolicyJSON {
|
||||
automatic: ApiFeaturePolicy[];
|
||||
manual: ApiFeaturePolicy[];
|
||||
current_user: ApiUserFeaturePolicy;
|
||||
}
|
||||
|
||||
// See app/serializers/rest/account_serializer.rb
|
||||
export interface BaseApiAccountJSON {
|
||||
acct: string;
|
||||
|
|
@ -23,6 +43,7 @@ export interface BaseApiAccountJSON {
|
|||
indexable: boolean;
|
||||
display_name: string;
|
||||
emojis: ApiCustomEmojiJSON[];
|
||||
feature_approval: ApiFeaturePolicyJSON;
|
||||
fields: ApiAccountFieldJSON[];
|
||||
followers_count: number;
|
||||
following_count: number;
|
||||
|
|
|
|||
|
|
@ -129,7 +129,11 @@ export const CollectionAccounts: React.FC<{
|
|||
accountIds: suggestedAccountIds,
|
||||
isLoading: isLoadingSuggestions,
|
||||
searchAccounts,
|
||||
} = useSearchAccounts();
|
||||
} = useSearchAccounts({
|
||||
filterResults: (account) =>
|
||||
// Only suggest accounts who allow being featured/recommended
|
||||
account.feature_approval.current_user === 'automatic',
|
||||
});
|
||||
|
||||
const suggestedItems = suggestedAccountIds.map((id) => ({
|
||||
id,
|
||||
|
|
|
|||
|
|
@ -10,8 +10,10 @@ import { useAppDispatch } from 'mastodon/store';
|
|||
export function useSearchAccounts({
|
||||
resetOnInputClear = true,
|
||||
onSettled,
|
||||
filterResults,
|
||||
}: {
|
||||
onSettled?: (value: string) => void;
|
||||
filterResults?: (account: ApiAccountJSON) => boolean;
|
||||
resetOnInputClear?: boolean;
|
||||
} = {}) {
|
||||
const dispatch = useAppDispatch();
|
||||
|
|
@ -49,8 +51,9 @@ export function useSearchAccounts({
|
|||
},
|
||||
})
|
||||
.then((data) => {
|
||||
dispatch(importFetchedAccounts(data));
|
||||
setAccountIds(data.map((a) => a.id));
|
||||
const accounts = filterResults ? data.filter(filterResults) : data;
|
||||
dispatch(importFetchedAccounts(accounts));
|
||||
setAccountIds(accounts.map((a) => a.id));
|
||||
setLoadingState('idle');
|
||||
onSettled?.(value);
|
||||
})
|
||||
|
|
|
|||
|
|
@ -69,6 +69,11 @@ export const accountDefaultValues: AccountShape = {
|
|||
display_name: '',
|
||||
display_name_html: '',
|
||||
emojis: ImmutableList<CustomEmoji>(),
|
||||
feature_approval: {
|
||||
automatic: [],
|
||||
manual: [],
|
||||
current_user: 'missing',
|
||||
},
|
||||
fields: ImmutableList<AccountField>(),
|
||||
group: false,
|
||||
header: '',
|
||||
|
|
|
|||
|
|
@ -31,6 +31,11 @@ export const accountFactory: FactoryFunction<ApiAccountJSON> = ({
|
|||
created_at: '2023-01-01T00:00:00.000Z',
|
||||
discoverable: true,
|
||||
emojis: [],
|
||||
feature_approval: {
|
||||
automatic: [],
|
||||
manual: [],
|
||||
current_user: 'missing',
|
||||
},
|
||||
fields: [],
|
||||
followers_count: 0,
|
||||
following_count: 0,
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user