[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:
diondiondion authored and Claire committed 2026-02-19 22:04:05 +01:00
1 parent 79fba522e1
commit 5c47ed2d47
4 files changed
+36 -3

No files matched your search

@@ -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);
})