feature/default_network_editable
frankiebee 6 years ago
parent 7e64a578a4
commit c10fb3ce3f
  1. 8
      app/scripts/controllers/recent-blocks.js

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

Loading…
Cancel
Save