Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: handle balances when returned as null (when hub connected to getalby.com is offfline) #3312

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/app/context/AccountContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 }) => {
Expand Down Expand Up @@ -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("");
Expand Down
2 changes: 1 addition & 1 deletion src/app/screens/Options/TestConnection/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down