diff --git a/src/features/reactions/api/useAvailableReaction.test.ts b/src/features/reactions/api/useAvailableReaction.test.ts index e87c3ea9061..016d4a7e9b8 100644 --- a/src/features/reactions/api/useAvailableReaction.test.ts +++ b/src/features/reactions/api/useAvailableReaction.test.ts @@ -6,6 +6,9 @@ import { act, renderHook } from 'tests/utils' jest.mock('libs/network/NetInfoWrapper') jest.mock('libs/jwt/jwt') +jest.mock('features/auth/context/AuthContext', () => ({ + useAuthContext: jest.fn(() => ({ isLoggedIn: true })), +})) describe('useAvailableReaction', () => { beforeEach(() => { diff --git a/src/features/reactions/api/useAvailableReaction.ts b/src/features/reactions/api/useAvailableReaction.ts index b3256c03561..c02e332fc2e 100644 --- a/src/features/reactions/api/useAvailableReaction.ts +++ b/src/features/reactions/api/useAvailableReaction.ts @@ -2,10 +2,17 @@ import { useQuery } from 'react-query' import { api } from 'api/api' import { GetAvailableReactionsResponse } from 'api/gen' +import { useAuthContext } from 'features/auth/context/AuthContext' import { QueryKeys } from 'libs/queryKeys' export const useAvailableReaction = () => { - return useQuery([QueryKeys.AVAILABLE_REACTION], () => - api.getNativeV1ReactionAvailable() + const { isLoggedIn } = useAuthContext() + + return useQuery( + [QueryKeys.AVAILABLE_REACTION], + () => api.getNativeV1ReactionAvailable(), + { + enabled: isLoggedIn, + } ) }