Require following accounts before being able to add them to a collection (#37927)

This commit is contained in:
diondiondion authored and GitHub committed 2026-02-20 13:14:36 +00:00
1 parent 4d2ca8c92a
commit 68a7cd404d
7 files changed
+141 -21

No files matched your search

@@ -2,19 +2,22 @@ import { useRef, useState } from 'react';
import { useDebouncedCallback } from 'use-debounce';
import { fetchRelationships } from 'mastodon/actions/accounts';
import { importFetchedAccounts } from 'mastodon/actions/importer';
import { apiRequest } from 'mastodon/api';
import type { ApiAccountJSON } from 'mastodon/api_types/accounts';
import { useAppDispatch } from 'mastodon/store';
export function useSearchAccounts({
resetOnInputClear = true,
onSettled,
filterResults,
resetOnInputClear = true,
withRelationships = false,
}: {
onSettled?: (value: string) => void;
filterResults?: (account: ApiAccountJSON) => boolean;
resetOnInputClear?: boolean;
withRelationships?: boolean;
} = {}) {
const dispatch = useAppDispatch();
@@ -52,8 +55,12 @@ export function useSearchAccounts({
})
.then((data) => {
const accounts = filterResults ? data.filter(filterResults) : data;
const accountIds = accounts.map((a) => a.id);
dispatch(importFetchedAccounts(accounts));
setAccountIds(accounts.map((a) => a.id));
if (withRelationships) {
dispatch(fetchRelationships(accountIds));
}
setAccountIds(accountIds);
setLoadingState('idle');
onSettled?.(value);
})