Skip to content
This repository was archived by the owner on Aug 5, 2025. It is now read-only.

Commit efc6c37

Browse files
Merge pull request #563 from lifeomic/retry-queries-on-interval
Retry queries on interval
2 parents 5e2ff0a + 4aa95ad commit efc6c37

File tree

3 files changed

+17
-10
lines changed

3 files changed

+17
-10
lines changed

example/AppDemo.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import { authConfig, baseURL } from './storybook/helpers/oauthConfig';
2+
import { authConfig, baseURL, account } from './storybook/helpers/oauthConfig';
33
import { DeveloperConfigProvider, RootProviders, LoggedInStack } from '../src';
44
import { FhirExampleScreen } from './src/screens/FhirExampleScreen';
55

@@ -22,7 +22,7 @@ function App() {
2222
showPreLoginWarning: false,
2323
}}
2424
>
25-
<RootProviders account="mockaccount" authConfig={authConfig}>
25+
<RootProviders account={account ?? 'mockaccount'} authConfig={authConfig}>
2626
<LoggedInStack />
2727
</RootProviders>
2828
</DeveloperConfigProvider>

example/storybook/helpers/oauthConfig.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { AuthConfiguration } from 'react-native-app-auth';
2-
import { oauthConfig, apiBaseUrl } from '../../config';
2+
import { oauthConfig, apiBaseUrl, accountToUse } from '../../config';
33

44
export const authConfig: AuthConfiguration = {
55
clientId: oauthConfig.clientId,
@@ -18,3 +18,4 @@ export const authConfig: AuthConfiguration = {
1818
};
1919

2020
export const baseURL = apiBaseUrl;
21+
export const account = accountToUse;

src/hooks/useActiveProject.tsx

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -156,13 +156,19 @@ export const ActiveProjectContextProvider: React.FC<ActiveProjectContextProvider
156156
const state = calculateState();
157157

158158
useEffect(() => {
159-
if (
160-
!query.isRefetching &&
161-
state.status === 'not-a-patient' &&
162-
keepWaitingForPatientId
163-
) {
164-
query.refetchAll();
165-
}
159+
const intervalId = setInterval(() => {
160+
if (
161+
!query.isRefetching &&
162+
state.status === 'not-a-patient' &&
163+
keepWaitingForPatientId
164+
) {
165+
query.refetchAll();
166+
} else {
167+
clearInterval(intervalId);
168+
}
169+
}, 2000);
170+
171+
return () => clearInterval(intervalId);
166172
}, [keepWaitingForPatientId, query, state.status]);
167173

168174
// This effect handles setting the initial value in async storage.

0 commit comments

Comments
 (0)