From 79a99ac93bf1655b431471cf084bb718063c9928 Mon Sep 17 00:00:00 2001 From: Kevin Serrano Date: Tue, 11 Oct 2016 14:33:30 -0700 Subject: Move tos hash comparison logic from background to mm controller. --- app/scripts/metamask-controller.js | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) (limited to 'app/scripts/metamask-controller.js') diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index c763d571..29c62a85 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -7,6 +7,7 @@ const HostStore = require('./lib/remote-store.js').HostStore const Web3 = require('web3') const ConfigManager = require('./lib/config-manager') const extension = require('./lib/extension') +const newTOSHash = global.TOS_HASH module.exports = class MetamaskController { @@ -22,12 +23,15 @@ module.exports = class MetamaskController { this.idStore.setStore(this.ethStore) this.messageManager = messageManager this.publicConfigStore = this.initPublicConfigStore() + var currentFiat = this.configManager.getCurrentFiat() || 'USD' this.configManager.setCurrentFiat(currentFiat) this.configManager.updateConversionRate() - var currentHash = this.configManager.getTOSHash() || 0 - this.configManager.setTOSHash(currentHash) + + this.checkTOSChange() + this.scheduleConversionInterval() + } getState () { @@ -266,22 +270,23 @@ module.exports = class MetamaskController { // config // - setTOSHash (hash, cb) { + setTOSHash (hash) { try { this.configManager.setTOSHash(hash) - cb(this.configManager.getTOSHash()) } catch (e) { - cb(null, e) + console.error('Error in setting terms of service hash.') } } - checkTOSChange (newHash, cb) { + checkTOSChange () { try { - var currentHash = this.configManager.getTOSHash() - var change = !(currentHash === newHash) - cb(change) + const storedHash = this.configManager.getTOSHash() || 0 + if (storedHash !== global.newTOSHash) { + this.resetDisclaimer() + this.setTOSHash(global.newTOSHash) + } } catch (e) { - cb(null, e) + console.error("Error in checking TOS change.") } } -- cgit