fix: Fix unauthenticated familiar followers request, #34911 (#34914)

This commit is contained in:
diondiondion 2025-06-04 10:25:10 +02:00 committed by GitHub
parent 37bf59f76a
commit b64ad77e21
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,6 +1,7 @@
import { useEffect } from 'react';
import { fetchAccountsFamiliarFollowers } from '@/mastodon/actions/accounts_familiar_followers';
import { useIdentity } from '@/mastodon/identity_context';
import { getAccountFamiliarFollowers } from '@/mastodon/selectors/accounts';
import { useAppDispatch, useAppSelector } from '@/mastodon/store';
import { me } from 'mastodon/initial_state';
@ -14,14 +15,15 @@ export const useFetchFamiliarFollowers = ({
const familiarFollowers = useAppSelector((state) =>
accountId ? getAccountFamiliarFollowers(state, accountId) : null,
);
const { signedIn } = useIdentity();
const hasNoData = familiarFollowers === null;
useEffect(() => {
if (hasNoData && accountId && accountId !== me) {
if (hasNoData && signedIn && accountId && accountId !== me) {
void dispatch(fetchAccountsFamiliarFollowers({ id: accountId }));
}
}, [dispatch, accountId, hasNoData]);
}, [dispatch, accountId, hasNoData, signedIn]);
return {
familiarFollowers: hasNoData ? [] : familiarFollowers,