1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-23 02:10:12 +01:00

Adds checkFeatureToggle util.

This commit is contained in:
Dan 2017-10-06 00:04:01 -02:30 committed by Chi Kei Chan
parent bbe893a0d8
commit 49f76d27a9
2 changed files with 13 additions and 4 deletions

View File

@ -2,6 +2,7 @@ const inherits = require('util').inherits
const Component = require('react').Component
const connect = require('react-redux').connect
const h = require('react-hyperscript')
const { checkFeatureToggle } = require('../lib/feature-toggle-utils')
const actions = require('./actions')
// init
const InitializeMenuScreen = require('./first-time/init-menu')
@ -334,11 +335,8 @@ App.prototype.renderPrimary = function () {
case 'sendTransaction':
log.debug('rendering send tx screen')
// Below param and ternary operator used for feature toggle
// Remove before merged to master
const windowParam = window.location.search.substr(1).split('=')
const SendComponentToRender = windowParam[0] === "ft" && windowParam[1] === "send-v2"
const SendComponentToRender = checkFeatureToggle('send-v2')
? SendTransactionScreen2
: SendTransactionScreen

View File

@ -0,0 +1,11 @@
function checkFeatureToggle(name) {
const queryPairMap = window.location.search.substr(1).split('&')
.map(pair => pair.split('='))
.reduce((pairs, [key, value]) => ({...pairs, [key]: value }), {})
const featureToggles = queryPairMap['ft'] ? queryPairMap['ft'].split(',') : []
return Boolean(featureToggles.find(ft => ft === name))
}
module.exports = {
checkFeatureToggle,
}