1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-22 18:00:18 +01:00
This commit is contained in:
frankiebee 2019-02-12 09:05:06 -10:00
parent 7e64a578a4
commit c10fb3ce3f

View File

@ -48,19 +48,19 @@ class RecentBlocksController {
log.error(err)
}
}
let isListeng = false
let isListening = false
const { type } = networkController.getProviderConfig()
if (!INFURA_PROVIDER_TYPES.includes(type) && type !== 'loading') {
this.blockTracker.on('latest', blockListner)
isListeng = true
isListening = true
}
networkController.on('networkDidChange', (newType) => {
if (INFURA_PROVIDER_TYPES.includes(newType) && isListeng) {
if (INFURA_PROVIDER_TYPES.includes(newType) && isListening) {
this.blockTracker.removeListener('latest', blockListner)
} else if (
!INFURA_PROVIDER_TYPES.includes(type) &&
type !== 'loading' &&
!isListeng
!isListening
) {
this.blockTracker.on('latest', blockListner)