parent
37bf59f76a
commit
b64ad77e21
1 changed files with 4 additions and 2 deletions
|
@ -1,6 +1,7 @@
|
||||||
import { useEffect } from 'react';
|
import { useEffect } from 'react';
|
||||||
|
|
||||||
import { fetchAccountsFamiliarFollowers } from '@/mastodon/actions/accounts_familiar_followers';
|
import { fetchAccountsFamiliarFollowers } from '@/mastodon/actions/accounts_familiar_followers';
|
||||||
|
import { useIdentity } from '@/mastodon/identity_context';
|
||||||
import { getAccountFamiliarFollowers } from '@/mastodon/selectors/accounts';
|
import { getAccountFamiliarFollowers } from '@/mastodon/selectors/accounts';
|
||||||
import { useAppDispatch, useAppSelector } from '@/mastodon/store';
|
import { useAppDispatch, useAppSelector } from '@/mastodon/store';
|
||||||
import { me } from 'mastodon/initial_state';
|
import { me } from 'mastodon/initial_state';
|
||||||
|
@ -14,14 +15,15 @@ export const useFetchFamiliarFollowers = ({
|
||||||
const familiarFollowers = useAppSelector((state) =>
|
const familiarFollowers = useAppSelector((state) =>
|
||||||
accountId ? getAccountFamiliarFollowers(state, accountId) : null,
|
accountId ? getAccountFamiliarFollowers(state, accountId) : null,
|
||||||
);
|
);
|
||||||
|
const { signedIn } = useIdentity();
|
||||||
|
|
||||||
const hasNoData = familiarFollowers === null;
|
const hasNoData = familiarFollowers === null;
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (hasNoData && accountId && accountId !== me) {
|
if (hasNoData && signedIn && accountId && accountId !== me) {
|
||||||
void dispatch(fetchAccountsFamiliarFollowers({ id: accountId }));
|
void dispatch(fetchAccountsFamiliarFollowers({ id: accountId }));
|
||||||
}
|
}
|
||||||
}, [dispatch, accountId, hasNoData]);
|
}, [dispatch, accountId, hasNoData, signedIn]);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
familiarFollowers: hasNoData ? [] : familiarFollowers,
|
familiarFollowers: hasNoData ? [] : familiarFollowers,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue