aboutsummaryrefslogtreecommitdiffstats
path: root/ui/app/reducers/app.js
diff options
context:
space:
mode:
Diffstat (limited to 'ui/app/reducers/app.js')
-rw-r--r--ui/app/reducers/app.js170
1 files changed, 133 insertions, 37 deletions
diff --git a/ui/app/reducers/app.js b/ui/app/reducers/app.js
index 7ad1229e5..02f024f7c 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,19 +37,76 @@ 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',
},
- transForward: true, // Used to render transition direction
- isLoading: false, // Used to display loading indicator
- warning: null, // Used to display error text
+ // Used to render transition direction
+ transForward: true,
+ // Used to display loading indicator
+ isLoading: false,
+ // Used to display error text
+ warning: null,
+ buyView: {},
+ isMouseUser: false,
}, 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,
@@ -103,12 +161,40 @@ function reduceApp (state, action) {
transForward: action.value,
})
+ case actions.SHOW_ADD_TOKEN_PAGE:
+ return extend(appState, {
+ currentView: {
+ name: 'add-token',
+ context: appState.currentView.context,
+ },
+ transForward: action.value,
+ })
+
case actions.SHOW_IMPORT_PAGE:
return extend(appState, {
currentView: {
name: 'import-menu',
},
transForward: true,
+ warning: null,
+ })
+
+ case actions.SHOW_NEW_ACCOUNT_PAGE:
+ return extend(appState, {
+ currentView: {
+ name: 'new-account-page',
+ context: action.formToSelect,
+ },
+ transForward: true,
+ warning: null,
+ })
+
+ case actions.SET_NEW_ACCOUNT_FORM:
+ return extend(appState, {
+ currentView: {
+ name: appState.currentView.name,
+ context: action.formToSelect,
+ },
})
case actions.SHOW_INFO_PAGE:
@@ -120,7 +206,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',
@@ -159,6 +245,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: {
@@ -294,7 +390,7 @@ function reduceApp (state, action) {
return extend(appState, {
currentView: {
name: 'confTx',
- context: 0,
+ context: action.id ? indexForPending(state, action.id) : 0,
},
transForward: action.transForward,
warning: null,
@@ -315,7 +411,7 @@ 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 )
+ .filter(tx => tx.id !== action.value)
const hasOtherUnconfActions = otherUnconfActions.length > 0
if (hasOtherUnconfActions) {
@@ -389,6 +485,11 @@ function reduceApp (state, action) {
warning: action.value || 'Incorrect password. Try again.',
})
+ case actions.UNLOCK_SUCCEEDED:
+ return extend(appState, {
+ warning: '',
+ })
+
case actions.SHOW_LOADING:
return extend(appState, {
isLoading: true,
@@ -469,8 +570,9 @@ function reduceApp (state, action) {
name: 'buyEth',
context: appState.currentView.name,
},
+ identity: state.metamask.identities[action.value],
buyView: {
- subview: 'buyForm',
+ subview: 'Coinbase',
amount: '15.00',
buyAddress: action.value,
formView: {
@@ -480,36 +582,20 @@ function reduceApp (state, action) {
},
})
- case actions.UPDATE_BUY_ADDRESS:
- return extend(appState, {
- buyView: {
- subview: 'buyForm',
- formView: {
- coinbase: appState.buyView.formView.coinbase,
- shapeshift: appState.buyView.formView.shapeshift,
- },
- buyAddress: action.value,
- amount: appState.buyView.amount,
- },
- })
-
- case actions.UPDATE_COINBASE_AMOUNT:
+ case actions.ONBOARDING_BUY_ETH_VIEW:
return extend(appState, {
- buyView: {
- subview: 'buyForm',
- formView: {
- coinbase: true,
- shapeshift: false,
- },
- buyAddress: appState.buyView.buyAddress,
- amount: action.value,
+ transForward: true,
+ currentView: {
+ name: 'onboardingBuyEth',
+ context: appState.currentView.name,
},
+ identity: state.metamask.identities[action.value],
})
case actions.COINBASE_SUBVIEW:
return extend(appState, {
buyView: {
- subview: 'buyForm',
+ subview: 'Coinbase',
formView: {
coinbase: true,
shapeshift: false,
@@ -522,22 +608,22 @@ function reduceApp (state, action) {
case actions.SHAPESHIFT_SUBVIEW:
return extend(appState, {
buyView: {
- subview: 'buyForm',
+ subview: 'ShapeShift',
formView: {
coinbase: false,
shapeshift: true,
marketinfo: action.value.marketinfo,
coinOptions: action.value.coinOptions,
},
- buyAddress: appState.buyView.buyAddress,
- amount: appState.buyView.amount,
+ buyAddress: action.value.buyAddress || appState.buyView.buyAddress,
+ amount: appState.buyView.amount || 0,
},
})
case actions.PAIR_UPDATE:
return extend(appState, {
buyView: {
- subview: 'buyForm',
+ subview: 'ShapeShift',
formView: {
coinbase: false,
shapeshift: true,
@@ -573,6 +659,12 @@ function reduceApp (state, action) {
data: action.value.data,
},
})
+
+ case actions.SET_MOUSE_USER_STATE:
+ return extend(appState, {
+ isMouseUser: action.value,
+ })
+
default:
return appState
}
@@ -586,9 +678,9 @@ function checkUnconfActions (state) {
function getUnconfActionList (state) {
const { unapprovedTxs, unapprovedMsgs,
- unapprovedPersonalMsgs, network } = state.metamask
+ unapprovedPersonalMsgs, unapprovedTypedMessages, network } = state.metamask
- const unconfActionList = txHelper(unapprovedTxs, unapprovedMsgs, unapprovedPersonalMsgs, network)
+ const unconfActionList = txHelper(unapprovedTxs, unapprovedMsgs, unapprovedPersonalMsgs, unapprovedTypedMessages, network)
return unconfActionList
}
@@ -598,3 +690,7 @@ function indexForPending (state, txId) {
const index = unconfTxList.indexOf(match)
return index
}
+
+// function indexForLastPending (state) {
+// return getUnconfActionList(state).length
+// }