Skip to content

Commit

Permalink
fix for requested changes
Browse files Browse the repository at this point in the history
  • Loading branch information
frankiebee committed Jan 18, 2018
1 parent 5dc02d9 commit 7c81bf7
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
6 changes: 4 additions & 2 deletions app/scripts/controllers/network.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const createEventEmitterProxy = require('../lib/events-proxy.js')
const RPC_ADDRESS_LIST = require('../config.js').network
const DEFAULT_RPC = RPC_ADDRESS_LIST['rinkeby']
const INFURA_PROVIDER_TYPES = ['ropsten', 'rinkeby', 'kovan', 'mainnet']
const noop = function () {}

module.exports = class NetworkController extends EventEmitter {

Expand Down Expand Up @@ -58,7 +59,7 @@ module.exports = class NetworkController extends EventEmitter {
return this.getNetworkState() === 'loading'
}

lookupNetwork (cb = () => {}) {
lookupNetwork (cb = noop){
// Prevent firing when provider is not defined.
if (!this.ethQuery || !this.ethQuery.sendAsync) {
return log.warn('NetworkController - lookupNetwork aborted due to missing ethQuery')
Expand All @@ -67,11 +68,12 @@ module.exports = class NetworkController extends EventEmitter {
if (err) {
this.setNetworkState('loading')
console.error(err)
cb(err)
return
}
log.info('web3.getNetwork returned ' + network)
this.setNetworkState(network)
cb(err, network)
cb(null, network)
})
}

Expand Down
8 changes: 4 additions & 4 deletions app/scripts/metamask-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,17 @@ module.exports = class MetamaskController extends EventEmitter {
this.networkController = new NetworkController(initState.NetworkController)

// setup onLine lister for restarting the provider
if (this.platform.onLine) {
this.platform.onLine(() => {
if (this.platform.addOnLineListener) {
this.platform.addOnLineListener(() => {
// guard against premature firring of the event listener
if (this.provider) {
// start the provider up
// start the block tracker up
this.provider.stop()
this.provider.start()
}
// look up the network
this.networkController.lookupNetwork(() => {
this.emit('update', this.getState())
this.sendUpdate()
})
})
}
Expand Down
2 changes: 1 addition & 1 deletion app/scripts/platforms/extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class ExtensionPlatform {
return navigator.onLine
}

onLine (cb) {
addOnLineListener (cb) {
window.addEventListener('online', cb)
}
}
Expand Down

0 comments on commit 7c81bf7

Please sign in to comment.