From 5cfa7ca5360902ebe503d6aa5840e8c276491069 Mon Sep 17 00:00:00 2001 From: pbca26 Date: Sat, 29 Jul 2017 13:14:38 +0300 Subject: [PATCH] camera feature detection --- .../components/dashboard/qrModal/qrModal.js | 32 +++++++++++----- .../dashboard/qrModal/qrModal.render.js | 38 +++++++------------ .../components/dashboard/sendCoin/sendCoin.js | 26 ++++++++++++- .../dashboard/sendCoin/sendCoin.render.js | 17 +++++---- 4 files changed, 69 insertions(+), 44 deletions(-) diff --git a/react/src/components/dashboard/qrModal/qrModal.js b/react/src/components/dashboard/qrModal/qrModal.js index 2605f3d..0866cc9 100755 --- a/react/src/components/dashboard/qrModal/qrModal.js +++ b/react/src/components/dashboard/qrModal/qrModal.js @@ -13,7 +13,7 @@ class QRModal extends React.Component { super(props); this.state = { modalIsOpen: false, - error: '' + error: null, }; this.openModal = this.openModal.bind(this); this.closeModal = this.closeModal.bind(this); @@ -21,7 +21,7 @@ class QRModal extends React.Component { this.handleError = this.handleError.bind(this); document.body.addEventListener('click', this.closeModal); } - + handleScan(data) { if (data !== null) { if (this.props.mode === 'scan') { @@ -32,23 +32,35 @@ class QRModal extends React.Component { } handleError(err) { - this.setState({error: err}); + this.setState({ + error: err, + }); } openModal() { - this.setState({modalIsOpen: true}); + this.setState({ + modalIsOpen: true + }); + if (this.props.mode === 'scan') { ReactDOM.render( - , document.getElementById('webcam')); + , document.getElementById('webcam')); } } closeModal() { - this.setState({modalIsOpen: false}); + this.setState({ + modalIsOpen: false, + }); + if (this.props.mode === 'scan') { ReactDOM.unmountComponentAtNode(document.getElementById('webcam')); } diff --git a/react/src/components/dashboard/qrModal/qrModal.render.js b/react/src/components/dashboard/qrModal/qrModal.render.js index 9f63a5e..0524407 100644 --- a/react/src/components/dashboard/qrModal/qrModal.render.js +++ b/react/src/components/dashboard/qrModal/qrModal.render.js @@ -7,35 +7,29 @@ export const QRModalRender = function () { - + onClick={ this.openModal }> +