Skip to content

Commit

Permalink
🐛 : [FIX] LDD Sentry Type Error in Market (#6909)
Browse files Browse the repository at this point in the history
  • Loading branch information
mcayuelas-ledger committed May 24, 2024
1 parent 2ec9792 commit 6512191
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/beige-nails-pull.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@ledgerhq/live-common": patch
---

Fix Sentry TypeError in useMarketDataProvider + Refetch Some data only every day
2 changes: 2 additions & 0 deletions libs/ledger-live-common/src/market/v2/timers.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
export const REFETCH_TIME_ONE_MINUTE = 60 * 1000;

export const BASIC_REFETCH = 3; // nb minutes

export const ONE_DAY = 24 * 60 * 60 * 1000;
10 changes: 8 additions & 2 deletions libs/ledger-live-common/src/market/v2/useMarketDataProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { CryptoCurrency } from "@ledgerhq/types-cryptoassets";
import { useMemo } from "react";

import { currencyFormatter, format } from "../utils/currencyFormatter";
import { BASIC_REFETCH, REFETCH_TIME_ONE_MINUTE } from "./timers";
import { BASIC_REFETCH, ONE_DAY, REFETCH_TIME_ONE_MINUTE } from "./timers";

const cryptoCurrenciesList = [...listCryptoCurrencies(), ...listTokens()];

Expand All @@ -36,7 +36,9 @@ export function useMarketDataProvider() {

const liveCoinsList = useMemo(
() =>
supportedCurrencies?.filter(({ id }) => liveCompatibleIds.includes(id)).map(({ id }) => id),
(supportedCurrencies || [])
?.filter(({ id }) => liveCompatibleIds.includes(id))
.map(({ id }) => id),
[liveCompatibleIds, supportedCurrencies],
);

Expand Down Expand Up @@ -79,12 +81,16 @@ export const useSupportedCounterCurrencies = () =>
useQuery({
queryKey: [QUERY_KEY.SupportedCounterCurrencies],
queryFn: () => supportedCounterCurrencies(),
refetchOnWindowFocus: true,
staleTime: ONE_DAY,
});

export const useSupportedCurrencies = () =>
useQuery({
queryKey: [QUERY_KEY.SupportedCurrencies],
queryFn: () => getSupportedCoinsList(),
refetchOnWindowFocus: true,
staleTime: ONE_DAY,
});

export function useMarketData(props: MarketListRequestParams): MarketListRequestResult {
Expand Down

0 comments on commit 6512191

Please sign in to comment.