Skip to content

Commit

Permalink
clearDeepLink before connect and on disconnect
Browse files Browse the repository at this point in the history
  • Loading branch information
L03TJ3 committed Jun 29, 2023
1 parent 0c5a6d0 commit da8049d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/components/BlockNativeOnboard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ import { SupportedChains, AsyncStorage, getDevice } from '@gooddollar/web3sdk-v2
* @returns Connect Button or Empty
*/

export const clearDeeplink = () => {
const osName = getDevice().os.name
// temp solution for where it tries and open a deeplink for desktop app
if (['Linux', 'Windows', 'macOS', 'iOS'].includes(osName)) {
AsyncStorage.safeRemove('WALLETCONNECT_DEEPLINK_CHOICE')
}
}

export const OnboardConnectButton: FC = () => {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const [{ wallet, connecting }, connect, disconnect] = useConnectWallet()
Expand All @@ -31,14 +39,9 @@ export const OnboardConnectButton: FC = () => {
const onWalletConnect = async () => {
connectionStartedRef.current = true
sendData({ event: 'wallet_connect', action: 'wallet_connect_start' })
const osName = getDevice().os.name

try {
// temp solution for where it tries and open a deeplink for desktop app
if (['Linux', 'Windows', 'macOS', 'iOS'].includes(osName)) {
AsyncStorage.safeRemove('WALLETCONNECT_DEEPLINK_CHOICE')
}

clearDeeplink()
await connect()
} catch {
connectionStartedRef.current = false
Expand Down
2 changes: 2 additions & 0 deletions src/hooks/useActiveOnboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { AsyncStorage, useAppRestart } from '@gooddollar/web3sdk-v2'

import usePromise from './usePromise'
import useSendAnalyticsData from './useSendAnalyticsData'
import { clearDeeplink } from 'components/BlockNativeOnboard'

export type IsSupportedChainId = {
isSupported: boolean
Expand Down Expand Up @@ -243,6 +244,7 @@ export function useOnboardConnect(): OnboardConnectProps {
}

if (WalletConnectV2Labels.includes(prevConnected)) {
clearDeeplink()
promises.push(cleanupList(/wc@2/))
}

Expand Down

0 comments on commit da8049d

Please sign in to comment.