diff options
-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() }) }) |