Skip to content

Commit

Permalink
Fix: track hints only when popup is open
Browse files Browse the repository at this point in the history
  • Loading branch information
katspaugh committed Oct 27, 2023
1 parent c35bc78 commit b314ca3
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions src/components/walletconnect/WcSessionMananger/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const SESSION_INFO_TIMEOUT = 2000
const WcSessionManager = ({ sessions, uri }: WcSessionManagerProps) => {
const { safe, safeAddress } = useSafeInfo()
const { chainId } = safe
const { walletConnect, error, setError, setOpen } = useContext(WalletConnectContext)
const { walletConnect, error, setError, open, setOpen } = useContext(WalletConnectContext)
const [proposal, setProposal] = useState<Web3WalletTypes.SessionProposal>()
const [changedSession, setChangedSession] = useState<SessionTypes.Struct>()

Expand Down Expand Up @@ -120,23 +120,23 @@ const WcSessionManager = ({ sessions, uri }: WcSessionManagerProps) => {

// Track errors
useEffect(() => {
if (error) trackEvent({ ...WALLETCONNECT_EVENTS.SHOW_ERROR, label: error.message })
}, [error])
if (error && open) {
trackEvent({ ...WALLETCONNECT_EVENTS.SHOW_ERROR, label: error.message })
}
}, [error, open])

//
// UI states
//

// Nothing to show
if (!open) return null

// Error
if (error) {
return <WcErrorMessage error={error} onClose={onErrorReset} />
}

// Session proposal
if (proposal) {
return <WcProposalForm proposal={proposal} onApprove={onApprove} onReject={onReject} />
}

// Session info
if (changedSession) {
return (
Expand All @@ -147,6 +147,11 @@ const WcSessionManager = ({ sessions, uri }: WcSessionManagerProps) => {
)
}

// Session proposal
if (proposal) {
return <WcProposalForm proposal={proposal} onApprove={onApprove} onReject={onReject} />
}

// Connection form (initial state)
return <WcConnectionForm sessions={sessions} onDisconnect={onDisconnect} uri={uri} />
}
Expand Down

0 comments on commit b314ca3

Please sign in to comment.