mirror of
https://github.com/glitch-soc/mastodon.git
synced 2026-03-29 11:11:11 +02:00
[Glitch] Only suggest discoverable accounts in collection account editor
Port 39ff07bc89 to glitch-soc
Signed-off-by: Claire <claire.github-309c@sitedethib.com>
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -132,7 +132,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 'flavours/glitch/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: '',
|
||||
|
||||
Reference in New Issue
Block a user