Skip to content

Commit

Permalink
fix: mobile pairing logic
Browse files Browse the repository at this point in the history
  • Loading branch information
IsaccoSordo committed Jan 31, 2025
1 parent 21d0c22 commit 0fe9226
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import Alert from '../../../../components/alert'
import Alert from 'src/components/alert'
import useConnect from '../../hooks/useConnect'
import BugReportForm from 'src/components/bug-report-form'
import Info from 'src/components/info'
import PairOther from 'src/components/pair-other/pair-other'
import TopWallets from 'src/components/top-wallets'
import Wallets from 'src/components/wallets'
import { isIOS } from 'src/utils/platform'
import { isIOS, isMobileOS } from 'src/utils/platform'
import { StorageKey } from '@airgap/beacon-types'
import QR from 'src/components/qr'
import useWallets from '../../hooks/useWallets'
Expand Down Expand Up @@ -201,7 +201,7 @@ const PairingAlert: React.FC<ConfigurableAlertProps> = (props) => {
}
/>
)}
{!isMobile && wallet?.types.includes('desktop') && (
{!isMobileOS(window) && wallet?.types.includes('desktop') && (
<Info
border
title={`Connect with ${wallet?.name} Desktop App`}
Expand All @@ -220,15 +220,15 @@ const PairingAlert: React.FC<ConfigurableAlertProps> = (props) => {
]}
/>
)}
{!isMobile &&
{!isMobileOS(window) &&
(qrCode?.length ?? 0) &&
wallet?.types.includes('ios') &&
(wallet?.types.length as number) > 1 && <QRCode isMobile={false} />}
{!isMobile &&
{!isMobileOS(window) &&
(qrCode?.length ?? 0) &&
wallet?.types.includes('ios') &&
(wallet?.types.length as number) <= 1 && <QRCode isMobile={true} />}
{isMobile &&
{isMobileOS(window) &&
wallet?.types.includes('ios') &&
(!wallet?.supportedInteractionStandards?.includes('wallet_connect') || isWCWorking ? (
<Info
Expand All @@ -243,8 +243,8 @@ const PairingAlert: React.FC<ConfigurableAlertProps> = (props) => {
if (!wallet) {
return
}

handleDeepLinking(
wallet,
wallet.supportedInteractionStandards?.includes('wallet_connect')
? wcPayload
: p2pPayload
Expand Down Expand Up @@ -273,7 +273,7 @@ const PairingAlert: React.FC<ConfigurableAlertProps> = (props) => {
}

if (isMobile && wallet.types.includes('ios') && wallet.types.length === 1) {
handleDeepLinking(syncCode)
handleDeepLinking(wallet, syncCode)
} else {
handleUpdateQRCode(syncCode)
}
Expand Down
6 changes: 3 additions & 3 deletions packages/beacon-ui/src/ui/alert/hooks/useConnect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ const useConnect = (

if (isValid) {
if (isMobile && selectedWallet.types.includes('ios') && selectedWallet.types.length === 1) {
handleDeepLinking(wcPayload)
handleDeepLinking(selectedWallet, wcPayload)
} else {
setQRCode(wcPayload)
setInstallState(selectedWallet)
Expand Down Expand Up @@ -190,8 +190,8 @@ const useConnect = (
})
)
}

const handleDeepLinking = (uri: string) => {
const handleDeepLinking = (wallet: MergedWallet, uri: string) => {
localStorage.setItem(
StorageKey.LAST_SELECTED_WALLET,
JSON.stringify({
Expand Down

0 comments on commit 0fe9226

Please sign in to comment.