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 { withSnackbar } from 'notistack'
|
||||
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 ProviderAccessible from './components/ProviderInfo/ProviderAccessible'
|
||||
import UserDetails from './components/ProviderDetails/UserDetails'
|
||||
|
@ -25,8 +23,6 @@ type State = {
|
|||
}
|
||||
|
||||
class HeaderComponent extends React.PureComponent<Props, State> {
|
||||
providerListener: ?IntervalID
|
||||
|
||||
constructor(props) {
|
||||
super(props)
|
||||
|
||||
|
@ -35,10 +31,6 @@ class HeaderComponent extends React.PureComponent<Props, State> {
|
|||
}
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
// this.onConnect()
|
||||
}
|
||||
|
||||
componentDidCatch(error: Error, info: Info) {
|
||||
const { enqueueSnackbar, closeSnackbar } = this.props
|
||||
|
||||
|
@ -51,27 +43,9 @@ class HeaderComponent extends React.PureComponent<Props, State> {
|
|||
onDisconnect = () => {
|
||||
const { removeProvider, enqueueSnackbar, closeSnackbar } = this.props
|
||||
|
||||
clearInterval(this.providerListener)
|
||||
|
||||
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 = () => {
|
||||
const { hasError } = this.state
|
||||
const {
|
||||
|
|
|
@ -10,5 +10,9 @@ const removeProvider = createAction<string, *, *>(REMOVE_PROVIDER)
|
|||
export default (enqueueSnackbar: Function, closeSnackbar: Function) => (dispatch: ReduxDispatch<*>) => {
|
||||
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())
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue