Skip to content

Commit

Permalink
Only use integrated modal if client sends URI
Browse files Browse the repository at this point in the history
  • Loading branch information
jribbink committed Jul 30, 2024
1 parent 1320962 commit 0fabc37
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions components/views/ConnectWallet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ import { FCL_SERVICE_METHODS } from '../../helpers/constants'
import { toTitleCase } from '../../helpers/strings'
import { toLower } from 'rambda'
import * as fcl from '@onflow/fcl'
import { Fragment } from 'react'
import { Fragment, useCallback } from 'react'
import { Service } from '../../types'
import { useConfig } from '../../contexts/ConfigContext'

const CANNONICAL_SERVICE_NAMES = {
'WC/RPC': 'Mobile App',
Expand All @@ -32,14 +33,18 @@ export default function ConnectWallet({
onConnectQRCode,
wallet,
}: GetWalletProps) {
const connectService = async (service: Service) => {
// WC/RPC is a special case where we need to show a QR code within Discovery
if (service.method === 'WC/RPC') {
onConnectQRCode()
} else {
fcl.WalletUtils.redirect(service)
}
}
const { walletConnectUri } = useConfig()
const connectToService = useCallback(
async (service: Service) => {
// WC/RPC is a special case where we need to show a QR code within Discovery
if (service.method === 'WC/RPC' && walletConnectUri) {
onConnectQRCode()
} else {
fcl.WalletUtils.redirect(service)
}
},
[walletConnectUri, onConnectQRCode]
)

return (
<ViewLayout
Expand All @@ -62,7 +67,7 @@ export default function ConnectWallet({
)}`}
button={{
text: `Connect`,
onClick: () => connectService(service),
onClick: () => connectToService(service),
}}
unstyled
></WalletTypeCard>
Expand Down

0 comments on commit 0fabc37

Please sign in to comment.