Skip to content

Commit

Permalink
Prefer native over nested if no balance on restore [ENG-5478] (#697)
Browse files Browse the repository at this point in the history
* Prefer native over nested if no balance on restore

* Show no funds message if no accounts found
  • Loading branch information
victorkirov authored Oct 23, 2024
1 parent 06974f4 commit a9390e8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
7 changes: 5 additions & 2 deletions src/app/screens/restoreWallet/paymentAddressTypeSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export default function PaymentAddressTypeSelector({

useEffect(() => {
if (isLoading || !data) return;
const preferredType = data.nativeTotalSats > data.nestedTotalSats ? 'native' : 'nested';
const preferredType = data.nestedTotalSats > data.nativeTotalSats ? 'nested' : 'native';
onSelectedTypeChange(preferredType);
}, [data, isLoading]);

Expand All @@ -108,6 +108,8 @@ export default function PaymentAddressTypeSelector({

const onClickType = (type: BtcPaymentType) => () => onSelectedTypeChange(type);

const totalFunds = data.nativeTotalSats + data.nestedTotalSats;

return (
<Container>
<Title>{t('TITLE')}</Title>
Expand Down Expand Up @@ -143,7 +145,8 @@ export default function PaymentAddressTypeSelector({
/>
</TypesContainer>
<StyledP typography="body_m" color="white_200">
{t('ACCOUNT_SUMMARY_DESCRIPTION')}
{totalFunds !== 0n && t('ACCOUNT_SUMMARY_DESCRIPTION')}
{totalFunds === 0n && t('ACCOUNT_SUMMARY_DESCRIPTION_NO_FUNDS')}
</StyledP>
</SummaryContainer>
</BodyContainer>
Expand Down
3 changes: 2 additions & 1 deletion src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,8 @@
"DESCRIPTION": "Select the default address type you would like to use for all accounts. You can switch at any time from settings.",
"LEARN_MORE": "Learn more about address types.",
"ACCOUNT_COUNT": "Accounts: {{accounts}}",
"ACCOUNT_SUMMARY_DESCRIPTION": "The balances shown are cumulative across all accounts for each address type."
"ACCOUNT_SUMMARY_DESCRIPTION": "The balances shown are cumulative across all accounts for each address type.",
"ACCOUNT_SUMMARY_DESCRIPTION_NO_FUNDS": "No balances found for this seed phrase."
}
},
"STACKING_SCREEN": {
Expand Down

0 comments on commit a9390e8

Please sign in to comment.