fix displaying multiple notifications on provider connect
This commit is contained in:
parent
6c99942530
commit
b23af71a1e
|
@ -8,9 +8,10 @@ import Portis from '@portis/web3'
|
||||||
import Fortmatic from 'fortmatic'
|
import Fortmatic from 'fortmatic'
|
||||||
import Button from '~/components/layout/Button'
|
import Button from '~/components/layout/Button'
|
||||||
import { fetchProvider } from '~/logic/wallets/store/actions'
|
import { fetchProvider } from '~/logic/wallets/store/actions'
|
||||||
|
import { getNetwork } from '~/config'
|
||||||
|
|
||||||
const web3Connect = new Web3Connect.Core({
|
const web3Connect = new Web3Connect.Core({
|
||||||
network: 'rinkeby',
|
network: getNetwork().toLowerCase(),
|
||||||
providerOptions: {
|
providerOptions: {
|
||||||
walletconnect: {
|
walletconnect: {
|
||||||
package: WalletConnectProvider,
|
package: WalletConnectProvider,
|
||||||
|
@ -39,15 +40,20 @@ type Props = {
|
||||||
closeSnackbar: Function,
|
closeSnackbar: Function,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let web3connectEventListenerAdded = false
|
||||||
|
|
||||||
const ConnectButton = ({
|
const ConnectButton = ({
|
||||||
registerProvider, enqueueSnackbar, closeSnackbar, ...props
|
registerProvider, enqueueSnackbar, closeSnackbar, ...props
|
||||||
}: Props) => {
|
}: Props) => {
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
if (!web3connectEventListenerAdded) {
|
||||||
web3Connect.on('connect', (provider: any) => {
|
web3Connect.on('connect', (provider: any) => {
|
||||||
if (provider) {
|
if (provider) {
|
||||||
registerProvider(provider, enqueueSnackbar, closeSnackbar)
|
registerProvider(provider, enqueueSnackbar, closeSnackbar)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
web3connectEventListenerAdded = true
|
||||||
|
}
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -52,12 +52,12 @@ const cancellationTxNotificationsQueue: NotificationsQueue = {
|
||||||
const ownerChangeTxNotificationsQueue: NotificationsQueue = {
|
const ownerChangeTxNotificationsQueue: NotificationsQueue = {
|
||||||
beforeExecution: NOTIFICATIONS.SIGN_OWNER_CHANGE_MSG,
|
beforeExecution: NOTIFICATIONS.SIGN_OWNER_CHANGE_MSG,
|
||||||
pendingExecution: {
|
pendingExecution: {
|
||||||
noMoreConfirmationsNeeded: NOTIFICATIONS.ONWER_CHANGE_PENDING_MSG,
|
noMoreConfirmationsNeeded: NOTIFICATIONS.OWNER_CHANGE_PENDING_MSG,
|
||||||
moreConfirmationsNeeded: NOTIFICATIONS.ONWER_CHANGE_PENDING_MORE_CONFIRMATIONS_MSG,
|
moreConfirmationsNeeded: NOTIFICATIONS.OWNER_CHANGE_PENDING_MORE_CONFIRMATIONS_MSG,
|
||||||
},
|
},
|
||||||
afterRejection: NOTIFICATIONS.ONWER_CHANGE_REJECTED_MSG,
|
afterRejection: NOTIFICATIONS.OWNER_CHANGE_REJECTED_MSG,
|
||||||
afterExecution: NOTIFICATIONS.OWNER_CHANGE_EXECUTED_MSG,
|
afterExecution: NOTIFICATIONS.OWNER_CHANGE_EXECUTED_MSG,
|
||||||
afterExecutionError: NOTIFICATIONS.ONWER_CHANGE_FAILED_MSG,
|
afterExecutionError: NOTIFICATIONS.OWNER_CHANGE_FAILED_MSG,
|
||||||
}
|
}
|
||||||
|
|
||||||
const safeNameChangeNotificationsQueue: NotificationsQueue = {
|
const safeNameChangeNotificationsQueue: NotificationsQueue = {
|
||||||
|
|
Loading…
Reference in New Issue