Skip to content

Commit

Permalink
Add FF refreshTime rate for LLD
Browse files Browse the repository at this point in the history
  • Loading branch information
mcayuelas-ledger committed Mar 12, 2024
1 parent 4289cc1 commit bc070f2
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { useFetchCurrencyFrom } from "@ledgerhq/live-common/exchange/swap/hooks/index";
import { useFeature } from "@ledgerhq/live-common/featureFlags/index";
import { MarketListRequestParams } from "@ledgerhq/live-common/market/types";
import { rangeDataTable } from "@ledgerhq/live-common/market/utils/rangeDataTable";
import {
Expand All @@ -20,6 +21,7 @@ import { localeSelector } from "~/renderer/reducers/settings";
export type MarketHookResult = {};

export function useMarket() {
const lldRefreshMarketDataFeature = useFeature("lldRefreshMarketData");
const { t } = useTranslation();
const dispatch = useDispatch();
const marketParams = useSelector(marketParamsSelector);
Expand All @@ -37,6 +39,9 @@ export function useMarket() {
...marketParams,
liveCoinsList,
supportedCoinsList: supportedCurrencies,
refreshTime: lldRefreshMarketDataFeature?.enabled
? Number(lldRefreshMarketDataFeature?.params?.refreshTime)
: undefined,
});

const { range, starred = [], liveCompatible, orderBy, order, search = "" } = marketParams;
Expand Down
6 changes: 6 additions & 0 deletions libs/ledger-live-common/src/featureFlags/defaultFeatures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,12 @@ export const DEFAULT_FEATURES: Features = {
},
supportDeviceStax: DEFAULT_FEATURE,
supportDeviceEuropa: DEFAULT_FEATURE,
lldRefreshMarketData: {
...DEFAULT_FEATURE,
params: {
refreshTime: 60000,
},
},
};

// Firebase SDK treat JSON values as strings
Expand Down
1 change: 1 addition & 0 deletions libs/ledger-live-common/src/market/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export type MarketListRequestParams = {
top100?: boolean;
supportedCoinsList?: SupportedCoins;
liveCoinsList?: string[];
refreshTime?: number;
};

export type MarketListRequestResult = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ export function useMarketData(props: MarketListRequestParams): MarketListRequest
{ ...props, page, liveCoinsList: [], supportedCoinsList: [] },
],
queryFn: () => fetchList({ ...props, page }),
refetchInterval: REFETCH_TIME,
staleTime: REFETCH_TIME,
refetchInterval: props.refreshTime ?? REFETCH_TIME,
staleTime: props.refreshTime ?? REFETCH_TIME,
})),
combine: results => {
return {
Expand Down
5 changes: 5 additions & 0 deletions libs/ledgerjs/packages/types-live/src/feature.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ export type Features = CurrencyFeatures & {
marketperformanceWidgetDesktop: Feature_MarketperformanceWidgetDesktop;
supportDeviceStax: Feature_SupportDeviceStax;
supportDeviceEuropa: Feature_SupportDeviceEuropa;
lldRefreshMarketData: Feature_LldRefreshMarketData;
};

/**
Expand Down Expand Up @@ -467,6 +468,10 @@ export type Feature_NftsFromSimpleHash = Feature<{
threshold: number;
}>;

export type Feature_LldRefreshMarketData = Feature<{
refreshTime: number;
}>;

export type Feature_CounterValue = DefaultFeature;
export type Feature_MockFeature = DefaultFeature;
export type Feature_MultibuyNavigation = DefaultFeature;
Expand Down

0 comments on commit bc070f2

Please sign in to comment.