mirror of
https://github.com/glitch-soc/mastodon.git
synced 2025-12-15 00:38:27 +00:00
[Glitch] fix: Fix unauthenticated familiar followers request
Port b64ad77e21 to glitch-soc
Signed-off-by: Claire <claire.github-309c@sitedethib.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
import { useEffect } from 'react';
|
import { useEffect } from 'react';
|
||||||
|
|
||||||
import { fetchAccountsFamiliarFollowers } from '@/flavours/glitch/actions/accounts_familiar_followers';
|
import { fetchAccountsFamiliarFollowers } from '@/flavours/glitch/actions/accounts_familiar_followers';
|
||||||
|
import { useIdentity } from '@/flavours/glitch/identity_context';
|
||||||
import { getAccountFamiliarFollowers } from '@/flavours/glitch/selectors/accounts';
|
import { getAccountFamiliarFollowers } from '@/flavours/glitch/selectors/accounts';
|
||||||
import { useAppDispatch, useAppSelector } from '@/flavours/glitch/store';
|
import { useAppDispatch, useAppSelector } from '@/flavours/glitch/store';
|
||||||
import { me } from 'flavours/glitch/initial_state';
|
import { me } from 'flavours/glitch/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,
|
||||||
|
|||||||
Reference in New Issue
Block a user