refactor: use loadLatestConfig() in place of loadLatest() where applicable
This commit is contained in:
parent
5342e9a8be
commit
cac88fda45
15 changed files with 52 additions and 56 deletions
|
|
@ -130,8 +130,8 @@ function checkStuckScreen (deviceEvents, machine) {
|
|||
}
|
||||
|
||||
function transactionNotify (tx, rec) {
|
||||
return settingsLoader.loadLatest().then(settings => {
|
||||
const notifSettings = configManager.getGlobalNotifications(settings.config)
|
||||
return settingsLoader.loadLatestConfig().then(config => {
|
||||
const notifSettings = configManager.getGlobalNotifications(config)
|
||||
const highValueTx = tx.fiat.gt(notifSettings.highValueTransaction || Infinity)
|
||||
const isCashOut = tx.direction === 'cashOut'
|
||||
|
||||
|
|
@ -147,7 +147,7 @@ function transactionNotify (tx, rec) {
|
|||
}
|
||||
|
||||
// alert through sms or email any transaction or high value transaction, if SMS || email alerts are enabled
|
||||
const walletSettings = configManager.getWalletSettings(tx.cryptoCode, settings.config)
|
||||
const walletSettings = configManager.getWalletSettings(tx.cryptoCode, config)
|
||||
const zeroConfLimit = walletSettings.zeroConfLimit || 0
|
||||
const zeroConf = isCashOut && tx.fiat.lte(zeroConfLimit)
|
||||
const notificationsEnabled = notifSettings.sms.transactions || notifSettings.email.transactions
|
||||
|
|
@ -308,8 +308,8 @@ function cashboxNotify (deviceId) {
|
|||
|
||||
// for notification center, check if type of notification is active before calling the respective notify function
|
||||
const notifyIfActive = (type, fnName, ...args) => {
|
||||
return settingsLoader.loadLatest().then(settings => {
|
||||
const notificationSettings = configManager.getGlobalNotifications(settings.config).notificationCenter
|
||||
return settingsLoader.loadLatestConfig().then(config => {
|
||||
const notificationSettings = configManager.getGlobalNotifications(config).notificationCenter
|
||||
if (!notificationCenter[fnName]) return Promise.reject(new Error(`Notification function ${fnName} for type ${type} does not exist`))
|
||||
if (!(notificationSettings.active && notificationSettings[type])) return Promise.resolve()
|
||||
return notificationCenter[fnName](...args)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue