From ea153f9c8473a160bf4d34b6f4a9eb4f3c892559 Mon Sep 17 00:00:00 2001 From: jorbuedo Date: Tue, 15 Oct 2024 15:17:25 +0200 Subject: [PATCH] fix(wallet-mobile): offline crashes (#3664) --- .../WalletManager/common/hooks/useBestBlock.tsx | 10 +++++++++- apps/wallet-mobile/src/yoroi-wallets/hooks/index.ts | 5 ++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/apps/wallet-mobile/src/features/WalletManager/common/hooks/useBestBlock.tsx b/apps/wallet-mobile/src/features/WalletManager/common/hooks/useBestBlock.tsx index ca667fc087..aae3f8b8f8 100644 --- a/apps/wallet-mobile/src/features/WalletManager/common/hooks/useBestBlock.tsx +++ b/apps/wallet-mobile/src/features/WalletManager/common/hooks/useBestBlock.tsx @@ -11,7 +11,15 @@ export const useBestBlock = ({options}: {options?: UseQueryOptions networkManager.api.bestBlock(), + queryFn: () => + networkManager.api.bestBlock().catch(() => ({ + // TODO: Without this it break when offline. Needs better fixing + epoch: 510, + slot: 130081, + globalSlot: 135086881, + hash: 'ab0093eb78bcb0146355741388632eb50c69407df8fa32de85e5f198d725e8f4', + height: 10850697, + })), ...options, }) diff --git a/apps/wallet-mobile/src/yoroi-wallets/hooks/index.ts b/apps/wallet-mobile/src/yoroi-wallets/hooks/index.ts index fb3ee1a9d8..29dbd086a9 100644 --- a/apps/wallet-mobile/src/yoroi-wallets/hooks/index.ts +++ b/apps/wallet-mobile/src/yoroi-wallets/hooks/index.ts @@ -440,7 +440,10 @@ export const useFrontendFees = ( suspense: true, queryKey: [wallet.id, 'frontend-fees'], ...options, - queryFn: () => wallet.api.getFrontendFees(), + queryFn: () => + wallet.api.getFrontendFees().catch(() => ({ + // TODO: Without this it break when offline. Needs better fixing + })), }) return {