aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts/responsive.js
blob: 512065309197f9c1175677bbde81cd39f68c36fb (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
const startPopup = require('./responsive-core')
const PortStream = require('./lib/port-stream.js')
const ExtensionPlatform = require('./platforms/extension')
const extension = require('extensionizer')
const NotificationManager = require('./lib/notification-manager')
const notificationManager = new NotificationManager()

// create platform global
global.platform = new ExtensionPlatform()

// inject css
const css = MetaMaskUiCss()
injectCss(css)

// setup stream to background
const extensionPort = extension.runtime.connect({ name: 'ui' })
const connectionStream = new PortStream(extensionPort)

// start ui
const container = document.getElementById('app-content')
startPopup({ container, connectionStream }, (err, store) => {
  if (err) return displayCriticalError(err)
  store.subscribe(() => {
    const state = store.getState()
  })
})

function displayCriticalError (err) {
  container.innerHTML = '<div class="critical-error">The MetaMask app failed to load: please open and close MetaMask again to restart.</div>'
  container.style.height = '80px'
  log.error(err.stack)
  throw err
}