diff options
author | Dan <danjm.com@gmail.com> | 2017-11-16 01:39:54 +0800 |
---|---|---|
committer | Dan <danjm.com@gmail.com> | 2017-12-05 10:38:23 +0800 |
commit | db06e7e649c5bdc98063bfeb7d7cbff999543c32 (patch) | |
tree | 9fff2b3fab229a1b5b6ddb1d48bca1c30ab1e8e9 /app | |
parent | ce14ee2ffcc784849ab42797d5c999b76ed57a78 (diff) | |
download | tangerine-wallet-browser-db06e7e649c5bdc98063bfeb7d7cbff999543c32.tar.gz tangerine-wallet-browser-db06e7e649c5bdc98063bfeb7d7cbff999543c32.tar.zst tangerine-wallet-browser-db06e7e649c5bdc98063bfeb7d7cbff999543c32.zip |
Css selected in background based on betaUI state.
Diffstat (limited to 'app')
-rw-r--r-- | app/scripts/popup.js | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/app/scripts/popup.js b/app/scripts/popup.js index 8cef06931..d0952af6a 100644 --- a/app/scripts/popup.js +++ b/app/scripts/popup.js @@ -1,5 +1,6 @@ const injectCss = require('inject-css') -const MetaMaskUiCss = require('../../ui/css') +const OldMetaMaskUiCss = require('../../old-ui/css') +const NewMetaMaskUiCss = require('../../ui/css') const startPopup = require('./popup-core') const PortStream = require('./lib/port-stream.js') const isPopupOrNotification = require('./lib/is-popup-or-notification') @@ -11,11 +12,6 @@ const notificationManager = new NotificationManager() // create platform global global.platform = new ExtensionPlatform() -// inject css -console.log(`MetaMaskUiCss`, MetaMaskUiCss); -const css = MetaMaskUiCss() -injectCss(css) - // identify window type (popup, notification) const windowType = isPopupOrNotification() global.METAMASK_UI_TYPE = windowType @@ -29,8 +25,21 @@ const connectionStream = new PortStream(extensionPort) const container = document.getElementById('app-content') startPopup({ container, connectionStream }, (err, store) => { if (err) return displayCriticalError(err) + + let betaUIState = store.getState().metamask.featureFlags.betaUI + let css = betaUIState ? NewMetaMaskUiCss() : OldMetaMaskUiCss() + let deleteInjectedCss = injectCss(css) + let newBetaUIState + store.subscribe(() => { const state = store.getState() + newBetaUIState = state.metamask.featureFlags.betaUI + if (newBetaUIState !== betaUIState) { + deleteInjectedCss() + betaUIState = newBetaUIState + css = betaUIState ? NewMetaMaskUiCss() : OldMetaMaskUiCss() + deleteInjectedCss = injectCss(css) + } if (state.appState.shouldClose) notificationManager.closePopup() }) }) |