Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

Commit

Permalink
Merge pull request #3430 from brave/fix/updateledgerinfo-refactor
Browse files Browse the repository at this point in the history
updateledgerinfo refactor
  • Loading branch information
bbondy authored Aug 27, 2016
2 parents 1ea3954 + f3524ab commit ebedb6c
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions app/ledger.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,11 @@ var boot = () => {
if (err.code !== 'ENOENT') console.log('statePath read error: ' + err.toString())

ledgerInfo.creating = true
appActions.updateLedgerInfo({ creating: true })
updateLedgerInfo()
try {
client = ledgerClient(null, underscore.extend({ roundtrip: roundtrip }, clientOptions), null)
} catch (ex) {
appActions.updateLedgerInfo({})
resetLedgerInfo()

bootP = false
return console.log('ledger client boot error: ' + ex.toString() + '\n' + ex.stack)
Expand All @@ -162,7 +162,7 @@ if (ipc) {
ipc.on(messages.CHECK_BITCOIN_HANDLER, () => {
if (typeof protocolHandler.isNavigatorProtocolHandled === 'function') {
ledgerInfo.hasBitcoinHandler = protocolHandler.isNavigatorProtocolHandled('', 'bitcoin')
appActions.updateLedgerInfo(underscore.omit(ledgerInfo, [ '_internal' ]))
updateLedgerInfo()
}
})

Expand Down Expand Up @@ -331,7 +331,8 @@ var initialize = (onoff) => {

if (!onoff) {
client = null
return appActions.updateLedgerInfo({})
resetLedgerInfo()
return
}
if (client) return

Expand Down Expand Up @@ -374,7 +375,7 @@ var initialize = (onoff) => {
}

if (err.code !== 'ENOENT') console.log('statePath read error: ' + err.toString())
appActions.updateLedgerInfo({})
resetLedgerInfo()
})
}

Expand Down Expand Up @@ -750,6 +751,10 @@ var updateLedgerInfo = () => {
appActions.updateLedgerInfo(underscore.omit(ledgerInfo, [ '_internal' ]))
}

var resetLedgerInfo = () => {
appActions.updateLedgerInfo({})
}

/*
* ledger client callbacks
*/
Expand Down

0 comments on commit ebedb6c

Please sign in to comment.