Skip to content

Commit

Permalink
Fixes #181
Browse files Browse the repository at this point in the history
  • Loading branch information
KKA11010 committed Sep 13, 2023
1 parent 664aae8 commit 8dc7ea7
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions src/screens/Payment/SelectMint.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import Screen from '@comps/Screen'
import Separator from '@comps/Separator'
import Txt from '@comps/Txt'
import { _testmintUrl } from '@consts'
import { l } from '@log'
import type { IMintBalWithName } from '@model'
import type { TSelectMintPageProps } from '@model/nav'
import { usePromptContext } from '@src/context/Prompt'
Expand Down Expand Up @@ -59,6 +60,7 @@ export default function SelectMintScreen({ navigation, route }: TSelectMintPageP
openPromptAutoClose({ msg: t('noFundsForFee', { ns: NS.common, fee: estFee }), ms: 4000 })
return
}
l('user has scanned an invoice, navigate to payment overview')
navigation.navigate('coinSelection', {
mint,
balance: mint.amount,
Expand All @@ -69,12 +71,25 @@ export default function SelectMintScreen({ navigation, route }: TSelectMintPageP
})
return
}
// choose a target for a lightning payment
// choose a target for a payment
if (isMelt || isSendEcash) {
// get remaining mints for a possible multimint swap
const remainingMints = userMints
.filter(m => m.mintUrl !== mint.mintUrl && m.mintUrl !== _testmintUrl)
.map(m => ({ mintUrl: m.mintUrl, customName: m.customName }))
// user has already selected a nostr target
if (nostr) {
l('user has already selected a nostr target, navigate to amount selection')
// select ecash amount to send
navigation.navigate('selectAmount', {
mint,
nostr,
balance: mint.amount,
isSendEcash
})
return
}
l('user wants to send payment, navigate to target selection')
navigation.navigate('selectTarget', {
mint,
balance: mint.amount,
Expand All @@ -84,14 +99,15 @@ export default function SelectMintScreen({ navigation, route }: TSelectMintPageP
})
return
}
// select ecash amount to send
l('[last condition] navigate to amount selection')
navigation.navigate('selectAmount', {
mint,
nostr,
balance: mint.amount,
isSendEcash
})
}

// Show user mints with balances and default mint icon
useEffect(() => {
void (async () => {
Expand All @@ -105,6 +121,7 @@ export default function SelectMintScreen({ navigation, route }: TSelectMintPageP
setDefaultM(await getDefaultMint() ?? '')
})()
}, [mints, mintsWithBal])

return (
<Screen
screenName={t(getScreenName(), { ns: NS.common })}
Expand Down

0 comments on commit 8dc7ea7

Please sign in to comment.