diff options
author | brunobar79 <brunobar79@gmail.com> | 2018-07-25 08:32:20 +0800 |
---|---|---|
committer | brunobar79 <brunobar79@gmail.com> | 2018-07-25 08:32:20 +0800 |
commit | 74fd6d1d1227d7a9e49623b73ee85985d79a1e46 (patch) | |
tree | 0329696b64e9f300c05919729d87dbb0dbd99655 /ui/app/components/send | |
parent | d5929e5c42e230fc0a52337f86b5850e68516563 (diff) | |
download | tangerine-wallet-browser-74fd6d1d1227d7a9e49623b73ee85985d79a1e46.tar tangerine-wallet-browser-74fd6d1d1227d7a9e49623b73ee85985d79a1e46.tar.gz tangerine-wallet-browser-74fd6d1d1227d7a9e49623b73ee85985d79a1e46.tar.bz2 tangerine-wallet-browser-74fd6d1d1227d7a9e49623b73ee85985d79a1e46.tar.lz tangerine-wallet-browser-74fd6d1d1227d7a9e49623b73ee85985d79a1e46.tar.xz tangerine-wallet-browser-74fd6d1d1227d7a9e49623b73ee85985d79a1e46.tar.zst tangerine-wallet-browser-74fd6d1d1227d7a9e49623b73ee85985d79a1e46.zip |
working without injection
Diffstat (limited to 'ui/app/components/send')
-rw-r--r-- | ui/app/components/send/send.component.js | 20 | ||||
-rw-r--r-- | ui/app/components/send/send.container.js | 2 | ||||
-rw-r--r-- | ui/app/components/send/send.selectors.js | 5 |
3 files changed, 22 insertions, 5 deletions
diff --git a/ui/app/components/send/send.component.js b/ui/app/components/send/send.component.js index 6c439cd21..fb7eef329 100644 --- a/ui/app/components/send/send.component.js +++ b/ui/app/components/send/send.component.js @@ -39,16 +39,26 @@ export default class SendTransactionScreen extends PersistentForm { updateSendErrors: PropTypes.func, updateSendTokenBalance: PropTypes.func, scanQrCode: PropTypes.func, + qrCodeData: PropTypes.object, }; static contextTypes = { t: PropTypes.func, }; - scanQrCode = async () => { - const scannedAddress = await this.props.scanQrCode() - this.props.updateSendTo(scannedAddress) - this.updateGas({ to: scannedAddress }) + componentWillReceiveProps (nextProps) { + if (nextProps.qrCodeData) { + if (nextProps.qrCodeData.type === 'address') { + const scannedAddress = nextProps.qrCodeData.values.address.toLowerCase() + const currentAddress = this.props.to && this.props.to.toLowerCase() + if (currentAddress !== scannedAddress) { + this.props.updateSendTo(scannedAddress) + this.updateGas({ to: scannedAddress }) + + // Here we should clear props.qrCodeData + } + } + } } updateGas ({ to: updatedToAddress, amount: value } = {}) { @@ -179,7 +189,7 @@ export default class SendTransactionScreen extends PersistentForm { <SendHeader history={history}/> <SendContent updateGas={(updateData) => this.updateGas(updateData)} - scanQrCode={_ => this.scanQrCode()} + scanQrCode={_ => this.props.scanQrCode()} /> <SendFooter history={history}/> </div> diff --git a/ui/app/components/send/send.container.js b/ui/app/components/send/send.container.js index 417941601..67a441a9d 100644 --- a/ui/app/components/send/send.container.js +++ b/ui/app/components/send/send.container.js @@ -21,6 +21,7 @@ import { getSendFromObject, getSendTo, getTokenBalance, + getQrCodeData, } from './send.selectors' import { updateSendTo, @@ -62,6 +63,7 @@ function mapStateToProps (state) { tokenBalance: getTokenBalance(state), tokenContract: getSelectedTokenContract(state), tokenToFiatRate: getSelectedTokenToFiatRate(state), + qrCodeData: getQrCodeData(state), } } diff --git a/ui/app/components/send/send.selectors.js b/ui/app/components/send/send.selectors.js index cf07eafe1..4e81d1f9e 100644 --- a/ui/app/components/send/send.selectors.js +++ b/ui/app/components/send/send.selectors.js @@ -46,6 +46,7 @@ const selectors = { getTokenExchangeRate, getUnapprovedTxs, transactionsSelector, + getQrCodeData, } module.exports = selectors @@ -282,3 +283,7 @@ function transactionsSelector (state) { : txsToRender .sort((a, b) => b.time - a.time) } + +function getQrCodeData (state) { + return state.appState.qrCodeData +}
\ No newline at end of file |