Skip to content

Commit

Permalink
Redirect WC Safe App to open popup
Browse files Browse the repository at this point in the history
  • Loading branch information
katspaugh committed Nov 1, 2023
1 parent df74e9a commit 2b1af01
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/pages/apps/open.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { NextPage } from 'next'
import { useRouter } from 'next/router'
import { useCallback } from 'react'
import { useCallback, useContext } from 'react'
import { Box, CircularProgress } from '@mui/material'

import { useSafeAppUrl } from '@/hooks/safe-apps/useSafeAppUrl'
Expand All @@ -15,6 +15,10 @@ import { useBrowserPermissions } from '@/hooks/safe-apps/permissions'
import useChainId from '@/hooks/useChainId'
import { AppRoutes } from '@/config/routes'
import { getOrigin } from '@/components/safe-apps/utils'
import { WalletConnectContext } from '@/services/walletconnect/WalletConnectContext'

// TODO: Remove this once we properly deprecate the WC app
const WC_SAFE_APP = /wallet-connect/

const SafeApps: NextPage = () => {
const chainId = useChainId()
Expand Down Expand Up @@ -42,6 +46,8 @@ const SafeApps: NextPage = () => {
remoteSafeAppsLoading,
})

const { setOpen } = useContext(WalletConnectContext)

const goToList = useCallback(() => {
router.push({
pathname: AppRoutes.apps.index,
Expand All @@ -52,6 +58,12 @@ const SafeApps: NextPage = () => {
// appUrl is required to be present
if (!appUrl || !router.isReady) return null

if (WC_SAFE_APP.test(appUrl)) {
setOpen(true)
goToList()
return null
}

if (isModalVisible) {
return (
<SafeAppsInfoModal
Expand Down

0 comments on commit 2b1af01

Please sign in to comment.