diff --git a/example/AppDemo.tsx b/example/AppDemo.tsx index 7e2ebfc3..019caa44 100644 --- a/example/AppDemo.tsx +++ b/example/AppDemo.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import { authConfig, baseURL } from './storybook/helpers/oauthConfig'; +import { authConfig, baseURL, account } from './storybook/helpers/oauthConfig'; import { DeveloperConfigProvider, RootProviders, LoggedInStack } from '../src'; import { FhirExampleScreen } from './src/screens/FhirExampleScreen'; @@ -22,7 +22,7 @@ function App() { showPreLoginWarning: false, }} > - + diff --git a/example/storybook/helpers/oauthConfig.ts b/example/storybook/helpers/oauthConfig.ts index d9b8814f..0bd64c7b 100644 --- a/example/storybook/helpers/oauthConfig.ts +++ b/example/storybook/helpers/oauthConfig.ts @@ -1,5 +1,5 @@ import { AuthConfiguration } from 'react-native-app-auth'; -import { oauthConfig, apiBaseUrl } from '../../config'; +import { oauthConfig, apiBaseUrl, accountToUse } from '../../config'; export const authConfig: AuthConfiguration = { clientId: oauthConfig.clientId, @@ -18,3 +18,4 @@ export const authConfig: AuthConfiguration = { }; export const baseURL = apiBaseUrl; +export const account = accountToUse; diff --git a/src/hooks/useActiveProject.tsx b/src/hooks/useActiveProject.tsx index 4556ad2a..a6f011f2 100644 --- a/src/hooks/useActiveProject.tsx +++ b/src/hooks/useActiveProject.tsx @@ -156,13 +156,19 @@ export const ActiveProjectContextProvider: React.FC { - if ( - !query.isRefetching && - state.status === 'not-a-patient' && - keepWaitingForPatientId - ) { - query.refetchAll(); - } + const intervalId = setInterval(() => { + if ( + !query.isRefetching && + state.status === 'not-a-patient' && + keepWaitingForPatientId + ) { + query.refetchAll(); + } else { + clearInterval(intervalId); + } + }, 2000); + + return () => clearInterval(intervalId); }, [keepWaitingForPatientId, query, state.status]); // This effect handles setting the initial value in async storage.