Skip to content

Commit

Permalink
fix: stop retrying of features request at top level (#759)
Browse files Browse the repository at this point in the history
  • Loading branch information
benwaples authored Aug 1, 2024
1 parent be9fcf8 commit 001f04c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion cmd/ui/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const Inner: React.FC = () => {
const authState = useAppSelector((state) => state.auth);
const queryClient = useQueryClient();
const location = useLocation();
const featureFlagsRes = useFeatureFlags();
const featureFlagsRes = useFeatureFlags({ retry: false });

const darkMode = useAppSelector((state) => state.global.view.darkMode);

Expand Down
5 changes: 3 additions & 2 deletions cmd/ui/src/hooks/useFeatureFlags.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// SPDX-License-Identifier: Apache-2.0

import { RequestOptions } from 'js-client-library';
import { useMutation, useQuery, useQueryClient } from 'react-query';
import { QueryOptions, UseQueryResult, useMutation, useQuery, useQueryClient } from 'react-query';
import { apiClient } from 'bh-shared-ui';

export type Flag = {
Expand All @@ -39,7 +39,8 @@ export const toggleFeatureFlag = (flagId: string | number, options?: RequestOpti
return apiClient.toggleFeatureFlag(flagId, options).then((response) => response.data);
};

export const useFeatureFlags = () => useQuery(featureFlagKeys.all, ({ signal }) => getFeatureFlags({ signal }));
export const useFeatureFlags = (queryOptions?: QueryOptions): UseQueryResult<Flag[], unknown> =>
useQuery(featureFlagKeys.all, ({ signal }) => getFeatureFlags({ signal }), queryOptions);

export const useFeatureFlag = (flagKey: string) =>
useQuery(featureFlagKeys.all, ({ signal }) => getFeatureFlags({ signal }), {
Expand Down

0 comments on commit 001f04c

Please sign in to comment.