Skip to content

Commit

Permalink
fix: reject session when manager closes
Browse files Browse the repository at this point in the history
  • Loading branch information
iamacook committed Sep 22, 2023
1 parent 690bbe1 commit bbc5eee
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
7 changes: 3 additions & 4 deletions src/components/walletconnect/HeaderWidget/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { Badge, Box } from '@mui/material'
import { useContext, useRef, useState } from 'react'

import { WalletConnectContext } from '@/services/walletconnect/WalletConnectContext'
import Popup from '../Popup'
import Icon from './Icon'
import SessionManager from '../SessionManager'

Expand All @@ -22,9 +21,9 @@ const WalletConnectHeaderWidget = () => {
<Badge color="error" variant="dot" invisible={!error} />
</div>

<Popup anchorEl={iconRef.current} open={popupOpen} onClose={() => setPopupOpen(false)}>
<SessionManager />
</Popup>
{iconRef.current && (
<SessionManager anchorEl={iconRef.current} open={popupOpen} onClose={() => setPopupOpen(false)} />
)}
</Box>
)
}
Expand Down
14 changes: 11 additions & 3 deletions src/components/walletconnect/SessionManager/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ import ProposalForm from '../ProposalForm'
import WcInput from '../WcInput'
import ErrorMessage from '@/components/tx/ErrorMessage'
import SessionList from '../SessionList'
import Popup from '../Popup'

const SessionManager = () => {
const SessionManager = ({ anchorEl, open, onClose }: { anchorEl: Element; open: boolean; onClose: () => void }) => {
const { safe, safeAddress } = useSafeInfo()
const { chainId } = safe
const { walletConnect, error: walletConnectError } = useContext(WalletConnectContext)
Expand Down Expand Up @@ -70,7 +71,14 @@ const SessionManager = () => {
}

return (
<>
<Popup
anchorEl={anchorEl}
open={open}
onClose={async () => {
await onReject()
onClose()
}}
>
{error && (
<ErrorMessage error={error}>Error establishing connection with WalletConnect. Please try again.</ErrorMessage>
)}
Expand All @@ -86,7 +94,7 @@ const SessionManager = () => {
<SessionList sessions={sessions} onDisconnect={onDisconnect} />
</>
)}
</>
</Popup>
)
}

Expand Down

0 comments on commit bbc5eee

Please sign in to comment.