From 4856aef1f0d0faac8f79fe8f8841d31c430c8f25 Mon Sep 17 00:00:00 2001 From: Dylan Nienberg Date: Thu, 14 Nov 2024 12:36:31 -0600 Subject: [PATCH] added Theo's changes --- VAMobile/src/api/auth/refreshAccessToken.tsx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/VAMobile/src/api/auth/refreshAccessToken.tsx b/VAMobile/src/api/auth/refreshAccessToken.tsx index 5679d289412..10bf1985719 100644 --- a/VAMobile/src/api/auth/refreshAccessToken.tsx +++ b/VAMobile/src/api/auth/refreshAccessToken.tsx @@ -1,8 +1,10 @@ import { useMutation } from '@tanstack/react-query' +import { dispatchUpdateLoadingRefreshToken } from 'store/slices' import { logNonFatalErrorToFirebase } from 'utils/analytics' import { clearStoredAuthCreds, processAuthResponse } from 'utils/auth' import getEnv from 'utils/env' +import { useAppDispatch } from 'utils/hooks' import { clearCookies } from 'utils/rnAuthSesson' const { AUTH_SIS_TOKEN_REFRESH_URL } = getEnv() @@ -26,11 +28,16 @@ const refreshAccessToken = (refreshToken: string): Promise => { * Returns a mutation for refreshing a user access token */ export const useRefreshAccessToken = () => { + const dispatch = useAppDispatch() return useMutation({ mutationFn: refreshAccessToken, onMutate: () => { + dispatch(dispatchUpdateLoadingRefreshToken(true)) clearCookies() }, + onSettled: () => { + dispatch(dispatchUpdateLoadingRefreshToken(false)) + }, onSuccess: (data) => { processAuthResponse(data) },