File tree Expand file tree Collapse file tree 2 files changed +11
-3
lines changed
apps/sq-server/src/main/js/apps/settings
libs/sq-server-commons/src/queries Expand file tree Collapse file tree 2 files changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ import { sortBy } from 'lodash';
2222import { Path } from 'react-router-dom' ;
2323import { InputSizeKeys } from '~design-system' ;
2424import { isDefined } from '~shared/helpers/types' ;
25+ import { addons } from '~sq-server-addons/index' ;
2526import { hasMessage , translate } from '~sq-server-commons/helpers/l10n' ;
2627import { getGlobalSettingsUrl , getProjectSettingsUrl } from '~sq-server-commons/helpers/urls' ;
2728import { usePurchasableFeaturesQuery } from '~sq-server-commons/queries/entitlements' ;
@@ -274,6 +275,11 @@ export function buildSettingLink(
274275}
275276
276277export function usePurchasableFeature ( featureKey : string ) {
277- const { data : purchasableFeatures = [ ] } = usePurchasableFeaturesQuery ( ) ;
278- return purchasableFeatures . find ( ( f ) => f . featureKey === featureKey ) ;
278+ const { data : purchasableFeatures } = usePurchasableFeaturesQuery ( {
279+ // Addons are only available in enterprise edition builds
280+ // so there's no need to call the query if the addon is not available.
281+ enabled : isDefined ( addons . license ) ,
282+ } ) ;
283+
284+ return purchasableFeatures ?. find ( ( f ) => f . featureKey === featureKey ) ;
279285}
Original file line number Diff line number Diff line change 1919 */
2020
2121import { queryOptions } from '@tanstack/react-query' ;
22- import { createQueryHook } from '~shared/queries/common' ;
22+ import { createQueryHook , StaleTime } from '~shared/queries/common' ;
2323import { getCurrentLicense , getPurchasableFeatures } from '../api/entitlements' ;
2424
2525export const LICENSE_QUERY_KEY = [ 'current-sqs-license' ] as const ;
@@ -28,12 +28,14 @@ export const useCurrentLicenseQuery = createQueryHook(() =>
2828 queryOptions ( {
2929 queryKey : LICENSE_QUERY_KEY ,
3030 queryFn : getCurrentLicense ,
31+ staleTime : StaleTime . NEVER ,
3132 } ) ,
3233) ;
3334
3435export const usePurchasableFeaturesQuery = createQueryHook ( ( ) =>
3536 queryOptions ( {
3637 queryKey : [ 'purchasable-features' ] ,
3738 queryFn : getPurchasableFeatures ,
39+ staleTime : StaleTime . NEVER ,
3840 } ) ,
3941) ;
You can’t perform that action at this time.
0 commit comments