From 080d730f20a9783e97c8e1fecc9d74ce52b51e85 Mon Sep 17 00:00:00 2001 From: Raul Duarte Pereira Date: Mon, 23 Oct 2023 17:05:12 -0300 Subject: [PATCH] CU-86a0yj0rj - Extend the WC connection time by 1 week everytime the user open the wallet --- app/containers/App/App.jsx | 16 ++++++++-------- app/containers/App/Sidebar/Logout/Logout.jsx | 3 --- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/app/containers/App/App.jsx b/app/containers/App/App.jsx index ef21ca50a..c686fc68c 100644 --- a/app/containers/App/App.jsx +++ b/app/containers/App/App.jsx @@ -14,6 +14,7 @@ import ErrorBoundary from '../../components/ErrorBoundaries/Main' import FramelessNavigation from '../../components/FramelessNavigation' import { parseQuery } from '../../core/formatters' import withSettingsContext from '../../hocs/withSettingsContext' +import { getInformationFromSession } from '../../util/walletConnect' const ipc = require('electron').ipcRenderer @@ -133,18 +134,17 @@ const App = ({ useEffect( () => { - const disconnectAllDaps = async () => { - await Promise.all(sessions.map(session => disconnect(session))) - ipc.send('closed') - } + if (!address || !sessions.length) return - ipc.on('quit', disconnectAllDaps) + const [{ address: connectedAddress }] = getInformationFromSession( + sessions[0], + ) - return () => { - ipc.off('quit', disconnectAllDaps) + if (connectedAddress !== address) { + Promise.all(sessions.map(session => disconnect(session))) } }, - [sessions, disconnect], + [address], ) return ( diff --git a/app/containers/App/Sidebar/Logout/Logout.jsx b/app/containers/App/Sidebar/Logout/Logout.jsx index a682a7bb2..1609f4513 100644 --- a/app/containers/App/Sidebar/Logout/Logout.jsx +++ b/app/containers/App/Sidebar/Logout/Logout.jsx @@ -3,7 +3,6 @@ import React from 'react' import classNames from 'classnames' import { FormattedMessage } from 'react-intl' -import { useWalletConnectWallet } from '@cityofzion/wallet-connect-sdk-wallet-react' import LogoutIcon from '../../../../assets/navigation/logout.svg' import styles from './Logout.scss' @@ -15,9 +14,7 @@ type Props = { } const Logout = ({ id, className, logout, promptHasBeenDisplayed }: Props) => { - const { sessions, disconnect } = useWalletConnectWallet() const handleClick = () => { - if (sessions) Promise.all(sessions.map(session => disconnect(session))) promptHasBeenDisplayed(false) logout() }