From a8bcd2453eac8cd999e50d88a8f3e94ea3c94e10 Mon Sep 17 00:00:00 2001 From: pavanjoshi914 Date: Fri, 28 Feb 2025 13:09:30 +0530 Subject: [PATCH] feat: hide balances if balance is returned as null (when hub connected to getalby.com is offline --- src/app/context/AccountContext.tsx | 10 ++++++++-- src/app/screens/Options/TestConnection/index.tsx | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/app/context/AccountContext.tsx b/src/app/context/AccountContext.tsx index 500895e9b2..616fb37f47 100644 --- a/src/app/context/AccountContext.tsx +++ b/src/app/context/AccountContext.tsx @@ -101,7 +101,9 @@ export function AccountProvider({ children }: { children: React.ReactNode }) { currency?: AccountInfo["currency"] ) => { const balance = getFormattedInCurrency(amount, currency); - setAccountBalance(balance); + Number.isFinite(amount) + ? setAccountBalance(balance) + : setAccountBalance(""); }; const fetchAccountInfo = async (options?: { accountId?: string }) => { @@ -170,7 +172,11 @@ export function AccountProvider({ children }: { children: React.ReactNode }) { // Listen to showFiat useEffect(() => { - if (showFiat && typeof account?.balance === "number") { + if ( + showFiat && + typeof account?.balance === "number" && + Number.isFinite(account.balance) + ) { updateFiatValue(account.balance); } else { setFiatBalance(""); diff --git a/src/app/screens/Options/TestConnection/index.tsx b/src/app/screens/Options/TestConnection/index.tsx index 12f1028f98..c183ad684b 100644 --- a/src/app/screens/Options/TestConnection/index.tsx +++ b/src/app/screens/Options/TestConnection/index.tsx @@ -168,7 +168,7 @@ export default function TestConnection() { accountName={accountInfo.name} alias={accountInfo.alias} satoshis={ - typeof accountInfo.balance === "number" + Number.isFinite(accountInfo.balance) ? getFormattedInCurrency( accountInfo.balance, accountInfo.currency