Skip to content

Commit

Permalink
Have to be logged in to call useAvailableReaction
Browse files Browse the repository at this point in the history
  • Loading branch information
cgerrard-pass committed Jan 10, 2025
1 parent 2e2f9ca commit 6554486
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/features/reactions/api/useAvailableReaction.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(() => {
Expand Down
11 changes: 9 additions & 2 deletions src/features/reactions/api/useAvailableReaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<GetAvailableReactionsResponse>([QueryKeys.AVAILABLE_REACTION], () =>
api.getNativeV1ReactionAvailable()
const { isLoggedIn } = useAuthContext()

return useQuery<GetAvailableReactionsResponse>(
[QueryKeys.AVAILABLE_REACTION],
() => api.getNativeV1ReactionAvailable(),
{
enabled: isLoggedIn,
}
)
}

0 comments on commit 6554486

Please sign in to comment.