fix displaying multiple notifications on provider connect

This commit is contained in:
mmv 2019-10-22 17:11:21 +04:00
parent 6c99942530
commit b23af71a1e
3 changed files with 16 additions and 10 deletions

View File

@ -8,9 +8,10 @@ import Portis from '@portis/web3'
import Fortmatic from 'fortmatic'
import Button from '~/components/layout/Button'
import { fetchProvider } from '~/logic/wallets/store/actions'
import { getNetwork } from '~/config'
const web3Connect = new Web3Connect.Core({
network: 'rinkeby',
network: getNetwork().toLowerCase(),
providerOptions: {
walletconnect: {
package: WalletConnectProvider,
@ -39,15 +40,20 @@ type Props = {
closeSnackbar: Function,
}
let web3connectEventListenerAdded = false
const ConnectButton = ({
registerProvider, enqueueSnackbar, closeSnackbar, ...props
}: Props) => {
useEffect(() => {
if (!web3connectEventListenerAdded) {
web3Connect.on('connect', (provider: any) => {
if (provider) {
registerProvider(provider, enqueueSnackbar, closeSnackbar)
}
})
web3connectEventListenerAdded = true
}
}, [])
return (

View File

@ -52,12 +52,12 @@ const cancellationTxNotificationsQueue: NotificationsQueue = {
const ownerChangeTxNotificationsQueue: NotificationsQueue = {
beforeExecution: NOTIFICATIONS.SIGN_OWNER_CHANGE_MSG,
pendingExecution: {
noMoreConfirmationsNeeded: NOTIFICATIONS.ONWER_CHANGE_PENDING_MSG,
moreConfirmationsNeeded: NOTIFICATIONS.ONWER_CHANGE_PENDING_MORE_CONFIRMATIONS_MSG,
noMoreConfirmationsNeeded: NOTIFICATIONS.OWNER_CHANGE_PENDING_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,
afterExecutionError: NOTIFICATIONS.ONWER_CHANGE_FAILED_MSG,
afterExecutionError: NOTIFICATIONS.OWNER_CHANGE_FAILED_MSG,
}
const safeNameChangeNotificationsQueue: NotificationsQueue = {