1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00

Merge pull request #2434 from danjm/NewUI-flat-clear-send-state

[NewUI] Clear send state on cancelling and signing.
This commit is contained in:
Chi Kei Chan 2017-10-23 11:49:14 -07:00 committed by GitHub
commit 9984c9516a
4 changed files with 31 additions and 7 deletions

View File

@ -143,6 +143,7 @@ var actions = {
UPDATE_SEND_AMOUNT: 'UPDATE_SEND_AMOUNT',
UPDATE_SEND_MEMO: 'UPDATE_SEND_MEMO',
UPDATE_SEND_ERRORS: 'UPDATE_SEND_ERRORS',
CLEAR_SEND: 'CLEAR_SEND',
updateGasLimit,
updateGasPrice,
updateGasTotal,
@ -151,6 +152,7 @@ var actions = {
updateSendAmount,
updateSendMemo,
updateSendErrors,
clearSend,
setSelectedAddress,
// app messages
confirmSeedWords: confirmSeedWords,
@ -577,13 +579,18 @@ function updateSendMemo (memo) {
}
function updateSendErrors (error) {
console.log(`updateSendErrors error`, error);
return {
type: actions.UPDATE_SEND_ERRORS,
value: error,
}
}
function clearSend () {
return {
type: actions.CLEAR_SEND
}
}
function sendTx (txData) {
log.info(`actions - sendTx: ${JSON.stringify(txData.txParams)}`)

View File

@ -80,5 +80,6 @@ function mapDispatchToProps (dispatch) {
updateSendMemo: newMemo => dispatch(actions.updateSendMemo(newMemo)),
updateSendErrors: newError => dispatch(actions.updateSendErrors(newError)),
goHome: () => dispatch(actions.goHome()),
clearSend: () => dispatch(actions.clearSend())
}
}

View File

@ -226,10 +226,6 @@ function reduceMetamask (state, action) {
})
case actions.UPDATE_SEND_ERRORS:
console.log(123, {
...metamaskState.send.errors,
...action.value,
})
return extend(metamaskState, {
send: {
...metamaskState.send,
@ -240,6 +236,20 @@ function reduceMetamask (state, action) {
},
})
case actions.CLEAR_SEND:
return extend(metamaskState, {
send: {
gasLimit: null,
gasPrice: null,
gasTotal: null,
from: '',
to: '',
amount: '0x0',
memo: '',
errors: {},
},
})
default:
return metamaskState

View File

@ -382,11 +382,14 @@ SendTransactionScreen.prototype.renderForm = function () {
}
SendTransactionScreen.prototype.renderFooter = function () {
const { goHome } = this.props
const { goHome, clearSend } = this.props
return h('div.send-v2__footer', [
h('button.send-v2__cancel-btn', {
onClick: goHome,
onClick: () => {
clearSend()
goHome()
},
}, 'Cancel'),
h('button.send-v2__next-btn', {
onClick: event => this.onSubmit(event),
@ -429,6 +432,7 @@ SendTransactionScreen.prototype.onSubmit = function (event) {
signTx,
selectedToken,
toAccounts,
clearSend,
} = this.props
this.addToAddressBookIfNew(to)
@ -445,6 +449,8 @@ SendTransactionScreen.prototype.onSubmit = function (event) {
txParams.to = to
}
clearSend()
selectedToken
? signTokenTx(selectedToken.address, to, amount, txParams)
: signTx(txParams)