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

Fixes trust popup while pasting token in dashboard on ios #208

Merged
merged 1 commit into from
Sep 13, 2023
Merged
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
6 changes: 3 additions & 3 deletions src/components/modal/TrustMint.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ export default function TrustMintModal({ loading, tokenInfo, handleTrustModal, c
{t('trustMint')}?
</Text>
{/* token amount */}
<Text style={[styles.mintPrompt, { color: color.TEXT_SECONDARY, }]}>
<Text style={[styles.mintPrompt, { color: color.TEXT }]}>
{formatInt(tokenInfo?.value || 0)} Satoshi {t('from')}:
</Text>
{/* Show in which mint(s) the tokens are */}
<View style={styles.tokenMintsView}>
{tokenInfo?.mints.map(m => <Text style={[styles.mintPrompt, { color: color.TEXT_SECONDARY, }]} key={m}>{formatMintUrl(m)}</Text>)}
{tokenInfo?.mints.map(m => <Text style={[styles.mintPrompt, { color: color.TEXT }]} key={m}>{formatMintUrl(m)}</Text>)}
</View>
<Text style={globals(color, highlight).modalTxt}>
{t('notClaim')}.
Expand All @@ -48,7 +48,7 @@ export default function TrustMintModal({ loading, tokenInfo, handleTrustModal, c

const styles = StyleSheet.create({
mintPrompt: {
fontSize: 12,
fontSize: 14,
marginBottom: 5,
},
tokenMintsView: {
Expand Down
12 changes: 9 additions & 3 deletions src/screens/Dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,13 @@ export default function Dashboard({ navigation, route }: TDashboardPageProps) {
// check if user wants to trust the token mint
const userMints = await getMintsUrls()
if (!hasTrustedMint(userMints, tokenInfo.mints)) {
closeOptsModal()
// ask user for permission if token mint is not in his mint list
setTrustModal(true)
stopLoading()
const t = setTimeout(() => {
setTrustModal(true)
stopLoading()
clearTimeout(t)
}, 250)
return
}
await receiveToken(url)
Expand All @@ -124,16 +128,17 @@ export default function Dashboard({ navigation, route }: TDashboardPageProps) {
// helper function that gets called either right after pasting token or in the trust modal depending on user permission
const receiveToken = async (encodedToken: string) => {
const success = await claimToken(encodedToken).catch(l)
setTrustModal(false)
closeOptsModal()
setToken('')
stopLoading()
if (!success) {
setTrustModal(false)
openPromptAutoClose({ msg: t('invalidOrSpent') })
return
}
const info = getTokenInfo(encodedToken)
if (!info) {
setTrustModal(false)
openPromptAutoClose({ msg: t('tokenInfoErr') })
return
}
Expand All @@ -144,6 +149,7 @@ export default function Dashboard({ navigation, route }: TDashboardPageProps) {
value: encodedToken,
mints: info.mints,
})
setTrustModal(false)
navigation.navigate('success', {
amount: info?.value,
memo: info?.decoded.memo,
Expand Down
Loading