Skip to content

Commit

Permalink
fix: show error toast if setupLdk fails
Browse files Browse the repository at this point in the history
  • Loading branch information
limpbrains committed Nov 22, 2024
1 parent 6610098 commit ea55544
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 7 deletions.
9 changes: 8 additions & 1 deletion src/screens/Settings/DevSettings/LdkDebug.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,14 @@ const LdkDebug = (): ReactElement => {

const onRestartLdk = async (): Promise<void> => {
setRestartingLdk(true);
await setupLdk({ selectedWallet, selectedNetwork });
const res = await setupLdk({ selectedWallet, selectedNetwork });
if (res.isErr()) {
showToast({
type: 'error',
title: t('wallet:ldk_start_error_title'),
description: res.error.message,
});
}
setRestartingLdk(false);
};

Expand Down
20 changes: 14 additions & 6 deletions src/screens/Settings/RGSServer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,23 @@ const RGSServer = ({
const connectToRGSServer = async (): Promise<void> => {
setLoading(true);
dispatch(updateSettings({ rapidGossipSyncUrl: rgsUrl }));
await setupLdk({
const res = await setupLdk({
selectedWallet,
selectedNetwork,
});
showToast({
type: 'success',
title: t('rgs.update_success_title'),
description: t('rgs.update_success_description'),
});
if (res.isOk()) {
showToast({
type: 'success',
title: t('rgs.update_success_title'),
description: t('rgs.update_success_description'),
});
} else {
showToast({
type: 'error',
title: t('wallet:ldk_start_error_title'),
description: res.error.message,
});
}
setLoading(false);
};

Expand Down
3 changes: 3 additions & 0 deletions src/utils/i18n/locales/en/wallet.json
Original file line number Diff line number Diff line change
Expand Up @@ -681,6 +681,9 @@
"ldk_sync_error_title": {
"string": "Lightning Sync Error"
},
"ldk_start_error_title": {
"string": "Lightning Startup Error"
},
"receive_insufficient_title": {
"string": "Insufficient receiving balance."
},
Expand Down
5 changes: 5 additions & 0 deletions src/utils/lightning/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -781,6 +781,11 @@ export const refreshLdk = async ({
shouldPreemptivelyStopLdk: false,
});
if (setupResponse.isErr()) {
showToast({
type: 'error',
title: i18n.t('wallet:ldk_start_error_title'),
description: setupResponse.error.message,
});
return handleRefreshError(setupResponse.error.message);
}
keepLdkSynced({ selectedNetwork }).then();
Expand Down
7 changes: 7 additions & 0 deletions src/utils/startup/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import { TWalletName } from '../../store/types/wallet';
import { runChecks } from '../wallet/checks';
import { setupLedger, syncLedger } from '../ledger';
import i18n from '../i18n';
import { showToast } from '../notifications';

/**
* Creates a new wallet from scratch
Expand Down Expand Up @@ -153,6 +154,12 @@ export const startWalletServices = async ({
});
if (setupResponse.isOk()) {
keepLdkSynced({ selectedNetwork }).then();
} else {
showToast({
type: 'error',
title: i18n.t('wallet:ldk_start_error_title'),
description: setupResponse.error.message,
});
}
}

Expand Down

0 comments on commit ea55544

Please sign in to comment.