diff options
author | frankiebee <frankie.diamond@gmail.com> | 2017-04-03 14:04:55 +0800 |
---|---|---|
committer | frankiebee <frankie.diamond@gmail.com> | 2017-04-03 14:04:55 +0800 |
commit | f81fdbc34ff037ab64a9f4c98100304e7b1132e4 (patch) | |
tree | 20f2a75068af1b4b13ecb9a9b6276e07af94de93 /ui | |
parent | 89c924101e3ff52849c5a82ced7e058e1fa39dfd (diff) | |
parent | 235a70b9392d8b87eae4fc141e7f0be1d7788ee2 (diff) | |
download | tangerine-wallet-browser-f81fdbc34ff037ab64a9f4c98100304e7b1132e4.tar tangerine-wallet-browser-f81fdbc34ff037ab64a9f4c98100304e7b1132e4.tar.gz tangerine-wallet-browser-f81fdbc34ff037ab64a9f4c98100304e7b1132e4.tar.bz2 tangerine-wallet-browser-f81fdbc34ff037ab64a9f4c98100304e7b1132e4.tar.lz tangerine-wallet-browser-f81fdbc34ff037ab64a9f4c98100304e7b1132e4.tar.xz tangerine-wallet-browser-f81fdbc34ff037ab64a9f4c98100304e7b1132e4.tar.zst tangerine-wallet-browser-f81fdbc34ff037ab64a9f4c98100304e7b1132e4.zip |
Merge branch 'master' into mascara
Diffstat (limited to 'ui')
-rw-r--r-- | ui/app/components/account-info-link.js | 3 | ||||
-rw-r--r-- | ui/app/components/buy-button-subview.js | 3 | ||||
-rw-r--r-- | ui/app/components/shift-list-item.js | 5 | ||||
-rw-r--r-- | ui/app/components/transaction-list-item.js | 2 | ||||
-rw-r--r-- | ui/app/info.js | 24 | ||||
-rw-r--r-- | ui/app/reducers/app.js | 55 | ||||
-rw-r--r-- | ui/index.js | 23 |
7 files changed, 52 insertions, 63 deletions
diff --git a/ui/app/components/account-info-link.js b/ui/app/components/account-info-link.js index 49c42e9ec..6526ab502 100644 --- a/ui/app/components/account-info-link.js +++ b/ui/app/components/account-info-link.js @@ -3,7 +3,6 @@ const h = require('react-hyperscript') const inherits = require('util').inherits const Tooltip = require('./tooltip') const genAccountLink = require('../../lib/account-link') -const extension = require('../../../app/scripts/lib/extension') module.exports = AccountInfoLink @@ -35,7 +34,7 @@ AccountInfoLink.prototype.render = function () { style: { margin: '5px', }, - onClick () { extension.tabs.create({ url }) }, + onClick () { global.platform.openWindow({ url }) }, }), ]), ]) diff --git a/ui/app/components/buy-button-subview.js b/ui/app/components/buy-button-subview.js index 7b993110d..2b1675b6d 100644 --- a/ui/app/components/buy-button-subview.js +++ b/ui/app/components/buy-button-subview.js @@ -5,7 +5,6 @@ const connect = require('react-redux').connect const actions = require('../actions') const CoinbaseForm = require('./coinbase-form') const ShapeshiftForm = require('./shapeshift-form') -const extension = require('../../../app/scripts/lib/extension') const Loading = require('./loading') const TabBar = require('./tab-bar') @@ -142,7 +141,7 @@ BuyButtonSubview.prototype.formVersionSubview = function () { } BuyButtonSubview.prototype.navigateTo = function (url) { - extension.tabs.create({ url }) + global.platform.openWindow({ url }) } BuyButtonSubview.prototype.backButtonContext = function () { diff --git a/ui/app/components/shift-list-item.js b/ui/app/components/shift-list-item.js index e0243e247..96a7cba6e 100644 --- a/ui/app/components/shift-list-item.js +++ b/ui/app/components/shift-list-item.js @@ -4,7 +4,6 @@ const h = require('react-hyperscript') const connect = require('react-redux').connect const vreme = new (require('vreme')) const explorerLink = require('../../lib/explorer-link') -const extension = require('../../../app/scripts/lib/extension') const actions = require('../actions') const addressSummary = require('../util').addressSummary @@ -172,9 +171,7 @@ ShiftListItem.prototype.renderInfo = function () { width: '200px', overflow: 'hidden', }, - onClick: () => extension.tabs.create({ - url, - }), + onClick: () => global.platform.openWindow({ url }), }, [ h('div', { style: { diff --git a/ui/app/components/transaction-list-item.js b/ui/app/components/transaction-list-item.js index ee32be7d3..0052d9c70 100644 --- a/ui/app/components/transaction-list-item.js +++ b/ui/app/components/transaction-list-item.js @@ -7,7 +7,7 @@ const addressSummary = require('../util').addressSummary const explorerLink = require('../../lib/explorer-link') const CopyButton = require('./copyButton') const vreme = new (require('vreme')) -const extension = require('../../../app/scripts/lib/extension') +const extension = require('extensionizer') const Tooltip = require('./tooltip') const TransactionIcon = require('./transaction-list-item-icon') diff --git a/ui/app/info.js b/ui/app/info.js index e79580be4..a6fdeb315 100644 --- a/ui/app/info.js +++ b/ui/app/info.js @@ -3,7 +3,6 @@ const Component = require('react').Component const h = require('react-hyperscript') const connect = require('react-redux').connect const actions = require('./actions') -const extension = require('../../app/scripts/lib/extension') module.exports = connect(mapStateToProps)(InfoScreen) @@ -17,13 +16,8 @@ function InfoScreen () { } InfoScreen.prototype.render = function () { - var state = this.props - var manifest - try { - manifest = extension.runtime.getManifest() - } catch (e) { - manifest = { version: '2.0.0' } - } + const state = this.props + const version = global.platform.getVersion() return ( h('.flex-column.flex-grow', [ @@ -53,7 +47,7 @@ InfoScreen.prototype.render = function () { style: { marginBottom: '10px', }, - }, `Version: ${manifest.version}`), + }, `Version: ${version}`), ]), h('div', { @@ -110,10 +104,12 @@ InfoScreen.prototype.render = function () { onClick (event) { this.navigateTo(event.target.href) }, }, [ h('img.icon-size', { - src: manifest.icons['128'], + src: 'images/icon-128.png', style: { - filter: 'grayscale(100%)', /* IE6-9 */ - WebkitFilter: 'grayscale(100%)', /* Microsoft Edge and Firefox 35+ */ + // IE6-9 + filter: 'grayscale(100%)', + // Microsoft Edge and Firefox 35+ + WebkitFilter: 'grayscale(100%)', }, }), h('div.info', 'Visit our web site'), @@ -139,7 +135,7 @@ InfoScreen.prototype.render = function () { h('a.info', { target: '_blank', style: { width: '85vw' }, - onClick () { extension.tabs.create({url: 'mailto:help@metamask.io?subject=Feedback'}) }, + onClick () { this.navigateTo('mailto:help@metamask.io?subject=Feedback') }, }, 'Email us!'), ]), @@ -158,5 +154,5 @@ InfoScreen.prototype.render = function () { } InfoScreen.prototype.navigateTo = function (url) { - extension.tabs.create({ url }) + global.platform.openWindow({ url }) } diff --git a/ui/app/reducers/app.js b/ui/app/reducers/app.js index 3a6baca91..7ad1229e5 100644 --- a/ui/app/reducers/app.js +++ b/ui/app/reducers/app.js @@ -1,20 +1,20 @@ const extend = require('xtend') const actions = require('../actions') const txHelper = require('../../lib/tx-helper') -const notification = require('../../../app/scripts/lib/notifications') module.exports = reduceApp + function reduceApp (state, action) { log.debug('App Reducer got ' + action.type) // clone and defaults const selectedAddress = state.metamask.selectedAddress - let pendingTxs = hasPendingTxs(state) + const hasUnconfActions = checkUnconfActions(state) let name = 'accounts' if (selectedAddress) { name = 'accountDetail' } - if (pendingTxs) { + if (hasUnconfActions) { log.debug('pending txs detected, defaulting to conf-tx view.') name = 'confTx' } @@ -32,7 +32,9 @@ function reduceApp (state, action) { seedWords, } + // default state var appState = extend({ + shouldClose: false, menuOpen: false, currentView: seedWords ? seedConfView : defaultView, accountDetail: { @@ -302,7 +304,7 @@ function reduceApp (state, action) { case actions.SHOW_CONF_MSG_PAGE: return extend(appState, { currentView: { - name: pendingTxs ? 'confTx' : 'account-detail', + name: hasUnconfActions ? 'confTx' : 'account-detail', context: 0, }, transForward: true, @@ -312,15 +314,11 @@ function reduceApp (state, action) { case actions.COMPLETED_TX: log.debug('reducing COMPLETED_TX for tx ' + action.value) - var { unapprovedTxs, unapprovedMsgs, - unapprovedPersonalMsgs, network } = state.metamask - - var unconfTxList = txHelper(unapprovedTxs, unapprovedMsgs, unapprovedPersonalMsgs, network) + const otherUnconfActions = getUnconfActionList(state) .filter(tx => tx.id !== action.value ) + const hasOtherUnconfActions = otherUnconfActions.length > 0 - pendingTxs = unconfTxList.length > 0 - - if (pendingTxs) { + if (hasOtherUnconfActions) { log.debug('reducer detected txs - rendering confTx view') return extend(appState, { transForward: false, @@ -332,9 +330,9 @@ function reduceApp (state, action) { }) } else { log.debug('attempting to close popup') - notification.closePopup() - return extend(appState, { + // indicate notification should close + shouldClose: true, transForward: false, warning: null, currentView: { @@ -580,26 +578,23 @@ function reduceApp (state, action) { } } -function hasPendingTxs (state) { - var { unapprovedTxs, unapprovedMsgs, +function checkUnconfActions (state) { + const unconfActionList = getUnconfActionList(state) + const hasUnconfActions = unconfActionList.length > 0 + return hasUnconfActions +} + +function getUnconfActionList (state) { + const { unapprovedTxs, unapprovedMsgs, unapprovedPersonalMsgs, network } = state.metamask - var unconfTxList = txHelper(unapprovedTxs, unapprovedMsgs, unapprovedPersonalMsgs, network) - var has = unconfTxList.length > 0 - return has + const unconfActionList = txHelper(unapprovedTxs, unapprovedMsgs, unapprovedPersonalMsgs, network) + return unconfActionList } function indexForPending (state, txId) { - var unapprovedTxs = state.metamask.unapprovedTxs - var unapprovedMsgs = state.metamask.unapprovedMsgs - var unapprovedPersonalMsgs = state.metamask.unapprovedPersonalMsgs - var network = state.metamask.network - var unconfTxList = txHelper(unapprovedTxs, unapprovedMsgs, unapprovedPersonalMsgs, network) - let idx - unconfTxList.forEach((tx, i) => { - if (tx.id === txId) { - idx = i - } - }) - return idx + const unconfTxList = getUnconfActionList(state) + const match = unconfTxList.find((tx) => tx.id === txId) + const index = unconfTxList.indexOf(match) + return index } diff --git a/ui/index.js b/ui/index.js index 16875fce4..a729138d3 100644 --- a/ui/index.js +++ b/ui/index.js @@ -4,26 +4,27 @@ const Root = require('./app/root') const actions = require('./app/actions') const configureStore = require('./app/store') const txHelper = require('./lib/tx-helper') -module.exports = launchApp +global.log = require('loglevel') -let debugMode = window.METAMASK_DEBUG -const log = require('loglevel') -window.log = log -log.setLevel(debugMode ? 'debug' : 'warn') +module.exports = launchMetamaskUi -function launchApp (opts) { + +log.setLevel(global.METAMASK_DEBUG ? 'debug' : 'warn') + +function launchMetamaskUi (opts, cb) { var accountManager = opts.accountManager actions._setBackgroundConnection(accountManager) // check if we are unlocked first accountManager.getState(function (err, metamaskState) { - if (err) throw err - startApp(metamaskState, accountManager, opts) + if (err) return cb(err) + const store = startApp(metamaskState, accountManager, opts) + cb(null, store) }) } function startApp (metamaskState, accountManager, opts) { // parse opts - var store = configureStore({ + const store = configureStore({ // metamaskState represents the cross-tab state metamask: metamaskState, @@ -36,7 +37,7 @@ function startApp (metamaskState, accountManager, opts) { }) // if unconfirmed txs, start on txConf page - var unapprovedTxsAll = txHelper(metamaskState.unapprovedTxs, metamaskState.unapprovedMsgs, metamaskState.unapprovedPersonalMsgs, metamaskState.network) + const unapprovedTxsAll = txHelper(metamaskState.unapprovedTxs, metamaskState.unapprovedMsgs, metamaskState.unapprovedPersonalMsgs, metamaskState.network) if (unapprovedTxsAll.length > 0) { store.dispatch(actions.showConfTxPage()) } @@ -52,4 +53,6 @@ function startApp (metamaskState, accountManager, opts) { store: store, } ), opts.container) + + return store } |