fix balance notification

This commit is contained in:
Josh Harvey 2016-04-27 21:16:13 +01:00
parent ec09aaeb7d
commit 6ee2566588
2 changed files with 5 additions and 3 deletions

View file

@ -5,7 +5,7 @@ var numeral = require('numeral')
var db = null
var getBalances = null
var LOW_BALANCE_THRESHOLD = 1000
var LOW_BALANCE_THRESHOLD = null
var STALE_STATE = 2 * 60 * 1000
var NETWORK_DOWN_TIME = 60 * 1000
@ -13,6 +13,8 @@ function init (_db, _getBalances, config) {
db = _db
getBalances = _getBalances
console.log('DEBUG2')
console.log(config)
if (config && config.lowBalanceThreshold) {
LOW_BALANCE_THRESHOLD = config.lowBalanceThreshold
}
@ -30,7 +32,7 @@ function sameState (a, b) {
}
function checkBalance (rec) {
return rec.fiatBalance < LOW_BALANCE_THRESHOLD
return LOW_BALANCE_THRESHOLD && rec.fiatBalance < LOW_BALANCE_THRESHOLD
? {code: 'lowBalance', cryptoCode: rec.cryptoCode, fiatBalance: rec.fiatBalance, fiatCode: rec.fiatCode}
: null
}