Skip to content

Commit

Permalink
fix: Only retry query when option is enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
bruce-glazier committed May 16, 2024
1 parent 28dbc94 commit 87841d6
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/hooks/useActiveProject.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { InviteRequiredScreen } from '../screens/InviteRequiredScreen';
import { useRestQuery } from './rest-api';
import { useActiveAccount } from './useActiveAccount';
import { useDeveloperConfig } from './useDeveloperConfig';
import { tID } from '../common/testID';

const selectedProjectIdKey = 'selectedProjectIdKey';

Expand Down Expand Up @@ -154,10 +155,14 @@ export const ActiveProjectContextProvider: React.FC<ActiveProjectContextProvider
const state = calculateState();

useEffect(() => {
if (!query.isRefetching && state.status === 'not-a-patient') {
if (
!query.isRefetching &&
state.status === 'not-a-patient' &&
keepWaitingForPatientId
) {
query.refetchAll();
}
}, [query, state.status]);
}, [keepWaitingForPatientId, query, state.status]);

// This effect handles setting the initial value in async storage.
const activeProjectId =
Expand All @@ -180,6 +185,7 @@ export const ActiveProjectContextProvider: React.FC<ActiveProjectContextProvider
if (keepWaitingForPatientId) {
return (
<ActivityIndicatorView
testID={tID('waiting-for-patient-loader')}
style={{
text: {
alignSelf: 'center',
Expand Down

0 comments on commit 87841d6

Please sign in to comment.