mirror of
https://github.com/status-im/safe-react.git
synced 2025-01-12 19:14:08 +00:00
remove info about current walletconnect session on disconnect
This commit is contained in:
parent
a263aba2fc
commit
065b91f899
@ -3,8 +3,6 @@ import * as React from 'react'
|
|||||||
import { connect } from 'react-redux'
|
import { connect } from 'react-redux'
|
||||||
import { withSnackbar } from 'notistack'
|
import { withSnackbar } from 'notistack'
|
||||||
import { logComponentStack, type Info } from '~/utils/logBoundaries'
|
import { logComponentStack, type Info } from '~/utils/logBoundaries'
|
||||||
import { getProviderInfo } from '~/logic/wallets/getWeb3'
|
|
||||||
import type { ProviderProps } from '~/logic/wallets/store/model/provider'
|
|
||||||
import { NOTIFICATIONS, showSnackbar } from '~/logic/notifications'
|
import { NOTIFICATIONS, showSnackbar } from '~/logic/notifications'
|
||||||
import ProviderAccessible from './components/ProviderInfo/ProviderAccessible'
|
import ProviderAccessible from './components/ProviderInfo/ProviderAccessible'
|
||||||
import UserDetails from './components/ProviderDetails/UserDetails'
|
import UserDetails from './components/ProviderDetails/UserDetails'
|
||||||
@ -25,8 +23,6 @@ type State = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class HeaderComponent extends React.PureComponent<Props, State> {
|
class HeaderComponent extends React.PureComponent<Props, State> {
|
||||||
providerListener: ?IntervalID
|
|
||||||
|
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props)
|
super(props)
|
||||||
|
|
||||||
@ -35,10 +31,6 @@ class HeaderComponent extends React.PureComponent<Props, State> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
|
||||||
// this.onConnect()
|
|
||||||
}
|
|
||||||
|
|
||||||
componentDidCatch(error: Error, info: Info) {
|
componentDidCatch(error: Error, info: Info) {
|
||||||
const { enqueueSnackbar, closeSnackbar } = this.props
|
const { enqueueSnackbar, closeSnackbar } = this.props
|
||||||
|
|
||||||
@ -51,27 +43,9 @@ class HeaderComponent extends React.PureComponent<Props, State> {
|
|||||||
onDisconnect = () => {
|
onDisconnect = () => {
|
||||||
const { removeProvider, enqueueSnackbar, closeSnackbar } = this.props
|
const { removeProvider, enqueueSnackbar, closeSnackbar } = this.props
|
||||||
|
|
||||||
clearInterval(this.providerListener)
|
|
||||||
|
|
||||||
removeProvider(enqueueSnackbar, closeSnackbar)
|
removeProvider(enqueueSnackbar, closeSnackbar)
|
||||||
}
|
}
|
||||||
|
|
||||||
onConnect = async () => {
|
|
||||||
const { fetchProvider, enqueueSnackbar, closeSnackbar } = this.props
|
|
||||||
|
|
||||||
clearInterval(this.providerListener)
|
|
||||||
let currentProvider: ProviderProps = await getProviderInfo()
|
|
||||||
fetchProvider(currentProvider, enqueueSnackbar, closeSnackbar)
|
|
||||||
|
|
||||||
this.providerListener = setInterval(async () => {
|
|
||||||
const newProvider: ProviderProps = await getProviderInfo()
|
|
||||||
if (currentProvider && JSON.stringify(currentProvider) !== JSON.stringify(newProvider)) {
|
|
||||||
fetchProvider(newProvider, enqueueSnackbar, closeSnackbar)
|
|
||||||
}
|
|
||||||
currentProvider = newProvider
|
|
||||||
}, 2000)
|
|
||||||
}
|
|
||||||
|
|
||||||
getProviderInfoBased = () => {
|
getProviderInfoBased = () => {
|
||||||
const { hasError } = this.state
|
const { hasError } = this.state
|
||||||
const {
|
const {
|
||||||
|
@ -10,5 +10,9 @@ const removeProvider = createAction<string, *, *>(REMOVE_PROVIDER)
|
|||||||
export default (enqueueSnackbar: Function, closeSnackbar: Function) => (dispatch: ReduxDispatch<*>) => {
|
export default (enqueueSnackbar: Function, closeSnackbar: Function) => (dispatch: ReduxDispatch<*>) => {
|
||||||
showSnackbar(NOTIFICATIONS.WALLET_DISCONNECTED_MSG, enqueueSnackbar, closeSnackbar)
|
showSnackbar(NOTIFICATIONS.WALLET_DISCONNECTED_MSG, enqueueSnackbar, closeSnackbar)
|
||||||
|
|
||||||
|
// remove info about current wallet connect session on disconnect so it's not used later
|
||||||
|
// TODO: use a method for killing the session from web3connect when they provide one
|
||||||
|
localStorage.removeItem('walletconnect')
|
||||||
|
|
||||||
dispatch(removeProvider())
|
dispatch(removeProvider())
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user