diff options
author | Alexander Tseung <alextsg@gmail.com> | 2018-04-17 14:03:47 +0800 |
---|---|---|
committer | Alexander Tseung <alextsg@gmail.com> | 2018-04-17 23:58:37 +0800 |
commit | b0a105ce809b8b7e5e4431bd1ddecc523586cad0 (patch) | |
tree | a1b0877175b6555dcded6bb61bc07e1ada81e12d /app/scripts/lib | |
parent | e4eb69dcc290a7e7eb27cab7ec57a8097345d81e (diff) | |
download | tangerine-wallet-browser-b0a105ce809b8b7e5e4431bd1ddecc523586cad0.tar tangerine-wallet-browser-b0a105ce809b8b7e5e4431bd1ddecc523586cad0.tar.gz tangerine-wallet-browser-b0a105ce809b8b7e5e4431bd1ddecc523586cad0.tar.bz2 tangerine-wallet-browser-b0a105ce809b8b7e5e4431bd1ddecc523586cad0.tar.lz tangerine-wallet-browser-b0a105ce809b8b7e5e4431bd1ddecc523586cad0.tar.xz tangerine-wallet-browser-b0a105ce809b8b7e5e4431bd1ddecc523586cad0.tar.zst tangerine-wallet-browser-b0a105ce809b8b7e5e4431bd1ddecc523586cad0.zip |
Fix confirmation popup not always opening
Diffstat (limited to 'app/scripts/lib')
-rw-r--r-- | app/scripts/lib/enums.js | 9 | ||||
-rw-r--r-- | app/scripts/lib/environment-type.js | 10 | ||||
-rw-r--r-- | app/scripts/lib/is-popup-or-notification.js | 12 | ||||
-rw-r--r-- | app/scripts/lib/util.js | 32 |
4 files changed, 33 insertions, 30 deletions
diff --git a/app/scripts/lib/enums.js b/app/scripts/lib/enums.js new file mode 100644 index 000000000..0a3afca47 --- /dev/null +++ b/app/scripts/lib/enums.js @@ -0,0 +1,9 @@ +const ENVIRONMENT_TYPE_POPUP = 'popup' +const ENVIRONMENT_TYPE_NOTIFICATION = 'notification' +const ENVIRONMENT_TYPE_FULLSCREEN = 'fullscreen' + +module.exports = { + ENVIRONMENT_TYPE_POPUP, + ENVIRONMENT_TYPE_NOTIFICATION, + ENVIRONMENT_TYPE_FULLSCREEN, +} diff --git a/app/scripts/lib/environment-type.js b/app/scripts/lib/environment-type.js deleted file mode 100644 index 7966926eb..000000000 --- a/app/scripts/lib/environment-type.js +++ /dev/null @@ -1,10 +0,0 @@ -module.exports = function environmentType () { - const url = window.location.href - if (url.match(/popup.html$/)) { - return 'popup' - } else if (url.match(/home.html$/)) { - return 'responsive' - } else { - return 'notification' - } -} diff --git a/app/scripts/lib/is-popup-or-notification.js b/app/scripts/lib/is-popup-or-notification.js deleted file mode 100644 index ad3e825c0..000000000 --- a/app/scripts/lib/is-popup-or-notification.js +++ /dev/null @@ -1,12 +0,0 @@ -module.exports = function isPopupOrNotification () { - const url = window.location.href - // if (url.match(/popup.html$/) || url.match(/home.html$/)) { - // Below regexes needed for feature toggles (e.g. see line ~340 in ui/app/app.js) - // Revert below regexes to above commented out regexes before merge to master - if (url.match(/popup.html(?:\?.+)*$/) || - url.match(/home.html(?:\?.+)*$/) || url.match(/home.html(?:#.*)*$/)) { - return 'popup' - } else { - return 'notification' - } -} diff --git a/app/scripts/lib/util.js b/app/scripts/lib/util.js index 6dee9edf0..df815906f 100644 --- a/app/scripts/lib/util.js +++ b/app/scripts/lib/util.js @@ -1,20 +1,27 @@ const ethUtil = require('ethereumjs-util') const assert = require('assert') const BN = require('bn.js') - -module.exports = { - getStack, - sufficientBalance, - hexToBn, - bnToHex, - BnMultiplyByFraction, -} +const { + ENVIRONMENT_TYPE_POPUP, + ENVIRONMENT_TYPE_NOTIFICATION, + ENVIRONMENT_TYPE_FULLSCREEN, +} = require('./enums') function getStack () { const stack = new Error('Stack trace generator - not an error').stack return stack } +const getEnvironmentType = (url = window.location.href) => { + if (url.match(/popup.html(?:\?.+)*$/)) { + return ENVIRONMENT_TYPE_POPUP + } else if (url.match(/home.html(?:\?.+)*$/) || url.match(/home.html(?:#.*)*$/)) { + return ENVIRONMENT_TYPE_FULLSCREEN + } else { + return ENVIRONMENT_TYPE_NOTIFICATION + } +} + function sufficientBalance (txParams, hexBalance) { // validate hexBalance is a hex string assert.equal(typeof hexBalance, 'string', 'sufficientBalance - hexBalance is not a hex string') @@ -42,3 +49,12 @@ function BnMultiplyByFraction (targetBN, numerator, denominator) { const denomBN = new BN(denominator) return targetBN.mul(numBN).div(denomBN) } + +module.exports = { + getStack, + getEnvironmentType, + sufficientBalance, + hexToBn, + bnToHex, + BnMultiplyByFraction, +} |