aboutsummaryrefslogtreecommitdiffstats
path: root/ui/app/reducers/app.js
diff options
context:
space:
mode:
authorChi Kei Chan <chikeichan@gmail.com>2017-10-19 13:58:46 +0800
committerChi Kei Chan <chikeichan@gmail.com>2017-10-19 13:58:46 +0800
commitc8c773d6416f92c520a509a9811d73f68aa00fc0 (patch)
tree495a798eeb4a5272c80d93725f5146a6fbcf85c8 /ui/app/reducers/app.js
parent5bdee96e73f65a0b369277e9c56b0afe5159e65b (diff)
parentde1da7d1b215ade650fc644adf63384a401dc240 (diff)
downloadtangerine-wallet-browser-c8c773d6416f92c520a509a9811d73f68aa00fc0.tar.gz
tangerine-wallet-browser-c8c773d6416f92c520a509a9811d73f68aa00fc0.tar.zst
tangerine-wallet-browser-c8c773d6416f92c520a509a9811d73f68aa00fc0.zip
Merge branch 'NewUI-flat' into merge
Diffstat (limited to 'ui/app/reducers/app.js')
-rw-r--r--ui/app/reducers/app.js133
1 files changed, 100 insertions, 33 deletions
diff --git a/ui/app/reducers/app.js b/ui/app/reducers/app.js
index 349c25b96..f10bf9fb7 100644
--- a/ui/app/reducers/app.js
+++ b/ui/app/reducers/app.js
@@ -14,6 +14,7 @@ function reduceApp (state, action) {
if (selectedAddress) {
name = 'accountDetail'
}
+
if (hasUnconfActions) {
log.debug('pending txs detected, defaulting to conf-tx view.')
name = 'confTx'
@@ -36,6 +37,17 @@ function reduceApp (state, action) {
var appState = extend({
shouldClose: false,
menuOpen: false,
+ modal: {
+ open: false,
+ modalState: {
+ name: null,
+ },
+ previousModalState: {
+ name: null,
+ }
+ },
+ sidebarOpen: false,
+ networkDropdownOpen: false,
currentView: seedWords ? seedConfView : defaultView,
accountDetail: {
subview: 'transactions',
@@ -49,9 +61,50 @@ function reduceApp (state, action) {
}, state.appState)
switch (action.type) {
+ // dropdown methods
+ case actions.NETWORK_DROPDOWN_OPEN:
+ return extend(appState, {
+ networkDropdownOpen: true,
+ })
- // transition methods
+ case actions.NETWORK_DROPDOWN_CLOSE:
+ return extend(appState, {
+ networkDropdownOpen: false,
+ })
+
+ // sidebar methods
+ case actions.SIDEBAR_OPEN:
+ return extend(appState, {
+ sidebarOpen: true,
+ })
+
+ case actions.SIDEBAR_CLOSE:
+ return extend(appState, {
+ sidebarOpen: false,
+ })
+
+ // modal methods:
+ case actions.MODAL_OPEN:
+ return extend(appState, {
+ modal: Object.assign(
+ state.appState.modal,
+ { open: true },
+ { modalState: action.payload },
+ { previousModalState: appState.modal.modalState},
+ ),
+ })
+
+ case actions.MODAL_CLOSE:
+ return extend(appState, {
+ modal: Object.assign(
+ state.appState.modal,
+ { open: false },
+ { modalState: { name: null } },
+ { previousModalState: appState.modal.modalState},
+ ),
+ })
+ // transition methods
case actions.TRANSITION_FORWARD:
return extend(appState, {
transForward: true,
@@ -133,7 +186,7 @@ function reduceApp (state, action) {
transForward: true,
})
- case actions.CREATE_NEW_VAULT_IN_PROGRESS:
+ case actions.CREATE_NEW_VAULT_IN_PROGRESS:
return extend(appState, {
currentView: {
name: 'createVault',
@@ -172,6 +225,16 @@ function reduceApp (state, action) {
warning: null,
})
+ case actions.SHOW_SEND_TOKEN_PAGE:
+ return extend(appState, {
+ currentView: {
+ name: 'sendToken',
+ context: appState.currentView.context,
+ },
+ transForward: true,
+ warning: null,
+ })
+
case actions.SHOW_NEW_KEYCHAIN:
return extend(appState, {
currentView: {
@@ -307,7 +370,7 @@ function reduceApp (state, action) {
return extend(appState, {
currentView: {
name: 'confTx',
- context: 0,
+ context: action.id ? indexForPending(state, action.id) : indexForLastPending(state),
},
transForward: action.transForward,
warning: null,
@@ -327,36 +390,36 @@ function reduceApp (state, action) {
case actions.COMPLETED_TX:
log.debug('reducing COMPLETED_TX for tx ' + action.value)
- const otherUnconfActions = getUnconfActionList(state)
- .filter(tx => tx.id !== action.value)
- const hasOtherUnconfActions = otherUnconfActions.length > 0
-
- if (hasOtherUnconfActions) {
- log.debug('reducer detected txs - rendering confTx view')
- return extend(appState, {
- transForward: false,
- currentView: {
- name: 'confTx',
- context: 0,
- },
- warning: null,
- })
- } else {
- log.debug('attempting to close popup')
- return extend(appState, {
- // indicate notification should close
- shouldClose: true,
- transForward: false,
- warning: null,
- currentView: {
- name: 'accountDetail',
- context: state.metamask.selectedAddress,
- },
- accountDetail: {
- subview: 'transactions',
- },
- })
- }
+ // const otherUnconfActions = getUnconfActionList(state)
+ // .filter(tx => tx.id !== action.value)
+ // const hasOtherUnconfActions = otherUnconfActions.length > 0
+
+ // if (hasOtherUnconfActions) {
+ // log.debug('reducer detected txs - rendering confTx view')
+ // return extend(appState, {
+ // transForward: false,
+ // currentView: {
+ // name: 'confTx',
+ // context: 0,
+ // },
+ // warning: null,
+ // })
+ // } else {
+ log.debug('attempting to close popup')
+ return extend(appState, {
+ // indicate notification should close
+ shouldClose: true,
+ transForward: false,
+ warning: null,
+ currentView: {
+ name: 'accountDetail',
+ context: state.metamask.selectedAddress,
+ },
+ accountDetail: {
+ subview: 'transactions',
+ },
+ })
+ // }
case actions.NEXT_TX:
return extend(appState, {
@@ -586,3 +649,7 @@ function indexForPending (state, txId) {
const index = unconfTxList.indexOf(match)
return index
}
+
+function indexForLastPending (state) {
+ return getUnconfActionList(state).length
+}