mirror of
https://github.com/glitch-soc/mastodon.git
synced 2025-01-31 20:12:55 -05:00
25 lines
720 B
TypeScript
25 lines
720 B
TypeScript
import {
|
|
apiGetSuggestions,
|
|
apiDeleteSuggestion,
|
|
} from 'mastodon/api/suggestions';
|
|
import { createDataLoadingThunk } from 'mastodon/store/typed_functions';
|
|
|
|
import { fetchRelationships } from './accounts';
|
|
import { importFetchedAccounts } from './importer';
|
|
|
|
export const fetchSuggestions = createDataLoadingThunk(
|
|
'suggestions/fetch',
|
|
() => apiGetSuggestions(20),
|
|
(data, { dispatch }) => {
|
|
dispatch(importFetchedAccounts(data.map((x) => x.account)));
|
|
dispatch(fetchRelationships(data.map((x) => x.account.id)));
|
|
|
|
return data;
|
|
},
|
|
);
|
|
|
|
export const dismissSuggestion = createDataLoadingThunk(
|
|
'suggestions/dismiss',
|
|
({ accountId }: { accountId: string }) => apiDeleteSuggestion(accountId),
|
|
);
|