From 5036263f88a1f61957982b64d27472a516c28def Mon Sep 17 00:00:00 2001 From: kumavis Date: Thu, 30 Mar 2017 18:33:19 -0700 Subject: introduce platform api and rename notifications to notification-manager --- ui/app/reducers/app.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ui/app/reducers/app.js') diff --git a/ui/app/reducers/app.js b/ui/app/reducers/app.js index 3a6baca91..6f633ab4e 100644 --- a/ui/app/reducers/app.js +++ b/ui/app/reducers/app.js @@ -1,7 +1,7 @@ const extend = require('xtend') const actions = require('../actions') const txHelper = require('../../lib/tx-helper') -const notification = require('../../../app/scripts/lib/notifications') +const notification = require('../../../app/scripts/lib/notification-manager') module.exports = reduceApp -- cgit v1.2.3 From bd704b1d7e7208fe1989bd7dde6ab81cb39bbfcc Mon Sep 17 00:00:00 2001 From: kumavis Date: Thu, 30 Mar 2017 19:05:11 -0700 Subject: etc - fix notification-manager ref, remove duplicated test file --- ui/app/reducers/app.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'ui/app/reducers/app.js') diff --git a/ui/app/reducers/app.js b/ui/app/reducers/app.js index 6f633ab4e..7595c60b3 100644 --- a/ui/app/reducers/app.js +++ b/ui/app/reducers/app.js @@ -1,7 +1,9 @@ const extend = require('xtend') const actions = require('../actions') const txHelper = require('../../lib/tx-helper') -const notification = require('../../../app/scripts/lib/notification-manager') +const NotificationManager = require('../../../app/scripts/lib/notification-manager') + +const notificationManager = new NotificationManager() module.exports = reduceApp @@ -332,7 +334,7 @@ function reduceApp (state, action) { }) } else { log.debug('attempting to close popup') - notification.closePopup() + notificationManager.closePopup() return extend(appState, { transForward: false, -- cgit v1.2.3 From 0ef679388a9604c39a432408826c080d2d17c221 Mon Sep 17 00:00:00 2001 From: kumavis Date: Fri, 31 Mar 2017 12:38:20 -0700 Subject: ui - reducer - app - code cleanup --- ui/app/reducers/app.js | 47 ++++++++++++++++++++--------------------------- 1 file changed, 20 insertions(+), 27 deletions(-) (limited to 'ui/app/reducers/app.js') diff --git a/ui/app/reducers/app.js b/ui/app/reducers/app.js index 7595c60b3..e0c001546 100644 --- a/ui/app/reducers/app.js +++ b/ui/app/reducers/app.js @@ -11,12 +11,12 @@ 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' } @@ -304,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, @@ -314,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, @@ -582,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 } -- cgit v1.2.3 From 49d8877fd78b8251b6856292ca71a55773a74b0e Mon Sep 17 00:00:00 2001 From: kumavis Date: Fri, 31 Mar 2017 13:20:16 -0700 Subject: ui - startPopup returns store after boot --- ui/app/reducers/app.js | 1 + 1 file changed, 1 insertion(+) (limited to 'ui/app/reducers/app.js') diff --git a/ui/app/reducers/app.js b/ui/app/reducers/app.js index e0c001546..46b27fe25 100644 --- a/ui/app/reducers/app.js +++ b/ui/app/reducers/app.js @@ -34,6 +34,7 @@ function reduceApp (state, action) { seedWords, } + // default state var appState = extend({ menuOpen: false, currentView: seedWords ? seedConfView : defaultView, -- cgit v1.2.3 From 60a48e713fb341c0eba893bd0c37e02315c8b320 Mon Sep 17 00:00:00 2001 From: kumavis Date: Fri, 31 Mar 2017 13:32:47 -0700 Subject: ui - move popup auto-close after tx conf to ui entrypoint --- ui/app/reducers/app.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'ui/app/reducers/app.js') diff --git a/ui/app/reducers/app.js b/ui/app/reducers/app.js index 46b27fe25..7ad1229e5 100644 --- a/ui/app/reducers/app.js +++ b/ui/app/reducers/app.js @@ -1,12 +1,10 @@ const extend = require('xtend') const actions = require('../actions') const txHelper = require('../../lib/tx-helper') -const NotificationManager = require('../../../app/scripts/lib/notification-manager') - -const notificationManager = new NotificationManager() module.exports = reduceApp + function reduceApp (state, action) { log.debug('App Reducer got ' + action.type) // clone and defaults @@ -36,6 +34,7 @@ function reduceApp (state, action) { // default state var appState = extend({ + shouldClose: false, menuOpen: false, currentView: seedWords ? seedConfView : defaultView, accountDetail: { @@ -331,9 +330,9 @@ function reduceApp (state, action) { }) } else { log.debug('attempting to close popup') - notificationManager.closePopup() - return extend(appState, { + // indicate notification should close + shouldClose: true, transForward: false, warning: null, currentView: { -- cgit v1.2.3