From 4a9d5b1c258912acedd6f1e89fb632526d9c910b Mon Sep 17 00:00:00 2001 From: Kevin Serrano Date: Thu, 21 Jul 2016 10:15:34 -0700 Subject: [PATCH] Add data field to pass up parameters up to reducer. --- app/scripts/lib/idStore.js | 4 +++- app/scripts/metamask-controller.js | 7 ++++++- ui/app/actions.js | 6 +++++- ui/app/reducers/metamask.js | 6 ++++++ 4 files changed, 20 insertions(+), 3 deletions(-) diff --git a/app/scripts/lib/idStore.js b/app/scripts/lib/idStore.js index 2c8e9108b..94aaad1d1 100644 --- a/app/scripts/lib/idStore.js +++ b/app/scripts/lib/idStore.js @@ -99,6 +99,8 @@ IdentityStore.prototype.getState = function () { unconfMsgs: messageManager.unconfirmedMsgs(), messages: messageManager.getMsgList(), selectedAddress: configManager.getSelectedAccount(), + currentFiat: configManager.getCurrentFiat(), + currentConversion: configManager.getConversionRate(), })) } @@ -199,7 +201,7 @@ IdentityStore.prototype.addUnconfirmedTransaction = function (txParams, onTxDone time: time, status: 'unconfirmed', } - + console.log('addUnconfirmedTransaction:', txData) // keep the onTxDoneCb around for after approval/denial (requires user interaction) diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index bcf5203fe..1b3b69932 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -241,8 +241,13 @@ module.exports = class MetamaskController { try { this.configManager.setCurrentFiat(fiat) this.configManager.setConversionRate() + const data = { + conversionRate: this.configManager.getConversionRate, + currentFiat: this.configManager.getCurrentFiat, + } + cb(data) } catch (e) { - cb(e) + cb(null,e) } } diff --git a/ui/app/actions.js b/ui/app/actions.js index c9a5401d3..c5fd2df08 100644 --- a/ui/app/actions.js +++ b/ui/app/actions.js @@ -212,10 +212,14 @@ function revealAccount () { function setCurrentFiat (fiat) { return (dispatch) => { dispatch(this.showLoadingIndication()) - _accountManager.setCurrentFiat(fiat, (err) => { + _accountManager.setCurrentFiat(fiat, (data, err) => { dispatch(this.hideLoadingIndication()) dispatch({ type: this.SET_CURRENT_FIAT, + value: { + currentFiat: data.currentFiat, + conversionRate: data.conversionRate, + } }) }) } diff --git a/ui/app/reducers/metamask.js b/ui/app/reducers/metamask.js index f3ef8eb11..d5d17135f 100644 --- a/ui/app/reducers/metamask.js +++ b/ui/app/reducers/metamask.js @@ -109,6 +109,12 @@ function reduceMetamask (state, action) { var identities = extend(metamaskState.identities, id) return extend(metamaskState, { identities }) + case actions.SET_CURRENT_FIAT: + return extend(metaMaskState, { + currentFiat: action.value.currentFiat, + conversionRate: action.value.conversionRate, + }) + default: return metamaskState