From 885b468e3e629a188589bac5898fb0bc633e9e08 Mon Sep 17 00:00:00 2001 From: pbca26 Date: Mon, 31 Jul 2017 19:43:48 +0300 Subject: [PATCH] refactored no video cam device error --- .../components/dashboard/qrModal/qrModal.js | 12 ++++++++--- .../dashboard/qrModal/qrModal.render.js | 8 ++++++- .../dashboard/receiveCoin/receiveCoin.js | 2 ++ .../components/dashboard/sendCoin/sendCoin.js | 21 ------------------- .../dashboard/sendCoin/sendCoin.render.js | 12 +++++------ .../dashboard/walletsNav/walletsNav.render.js | 4 ++-- 6 files changed, 25 insertions(+), 34 deletions(-) diff --git a/react/src/components/dashboard/qrModal/qrModal.js b/react/src/components/dashboard/qrModal/qrModal.js index eea82dd..7012919 100755 --- a/react/src/components/dashboard/qrModal/qrModal.js +++ b/react/src/components/dashboard/qrModal/qrModal.js @@ -32,9 +32,15 @@ class QRModal extends React.Component { } handleError(err) { - this.setState({ - error: err, - }); + if (err.name === 'NoVideoInputDevicesError') { + this.setState({ + error: 'Error: No video input devices found!', + }); + } else { + this.setState({ + error: 'Error: unknown error!', + }); + } } openModal() { diff --git a/react/src/components/dashboard/qrModal/qrModal.render.js b/react/src/components/dashboard/qrModal/qrModal.render.js index 0524407..db7d0eb 100644 --- a/react/src/components/dashboard/qrModal/qrModal.render.js +++ b/react/src/components/dashboard/qrModal/qrModal.render.js @@ -66,7 +66,13 @@ export const QRModalReaderRender = function () {
-
+
{ this.state.error }
diff --git a/react/src/components/dashboard/receiveCoin/receiveCoin.js b/react/src/components/dashboard/receiveCoin/receiveCoin.js index e440235..a3214fb 100644 --- a/react/src/components/dashboard/receiveCoin/receiveCoin.js +++ b/react/src/components/dashboard/receiveCoin/receiveCoin.js @@ -124,12 +124,14 @@ class ReceiveCoin extends React.Component { if (this.isBasiliskMode() && this.hasNoAmount(address)) { address.amount = _cache && _cache[_coin][address.address] && + _cache[_coin][address.address].getbalance && _cache[_coin][address.address].getbalance.data && _cache[_coin][address.address].getbalance.data.balance ? _cache[_coin][address.address].getbalance.data.balance : 'N/A'; } if (this.isBasiliskMode() && this.hasNoInterest(address)) { address.interest = _cache && _cache[_coin][address.address] && + _cache[_coin][address.address].getbalance && _cache[_coin][address.address].getbalance.data && _cache[_coin][address.address].getbalance.data.interest ? _cache[_coin][address.address].getbalance.data.interest : 'N/A'; } diff --git a/react/src/components/dashboard/sendCoin/sendCoin.js b/react/src/components/dashboard/sendCoin/sendCoin.js index 14a43f4..bf1fe94 100644 --- a/react/src/components/dashboard/sendCoin/sendCoin.js +++ b/react/src/components/dashboard/sendCoin/sendCoin.js @@ -55,7 +55,6 @@ class SendCoin extends React.Component { currentStackLength: 0, totalStackLength: 0, utxoMethodInProgress: false, - isCameraFeatureDetected: false, }; this.updateInput = this.updateInput.bind(this); this.handleBasiliskSend = this.handleBasiliskSend.bind(this); @@ -66,27 +65,9 @@ class SendCoin extends React.Component { this._fetchNewUTXOData = this._fetchNewUTXOData.bind(this); this.handleClickOutside = this.handleClickOutside.bind(this); this.setRecieverFromScan = this.setRecieverFromScan.bind(this); - this.detectCamera = this.detectCamera.bind(this); socket.on('messages', msg => this.updateSocketsData(msg)); } - // test device camera capabilities - detectCamera() { - const _getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia; - - _getUserMedia( - { 'video': true }, - function() { - this.setState({ - isCameraFeatureDetected: true, - }); - }, - function() { - console.warn('this device doesn\'t have camera!'); - } - ); - } - setRecieverFromScan(receiver) { this.setState({ sendTo: receiver @@ -101,8 +82,6 @@ class SendCoin extends React.Component { this.handleClickOutside, false ); - - this.detectCamera(); } componentWillUnmount() { diff --git a/react/src/components/dashboard/sendCoin/sendCoin.render.js b/react/src/components/dashboard/sendCoin/sendCoin.render.js index b9749b4..43672d8 100644 --- a/react/src/components/dashboard/sendCoin/sendCoin.render.js +++ b/react/src/components/dashboard/sendCoin/sendCoin.render.js @@ -163,13 +163,11 @@ export const SendApiTypeSelectorRender = function() {
- { this.state.isCameraFeatureDetected && -
- -
- } +
+ +
); }; diff --git a/react/src/components/dashboard/walletsNav/walletsNav.render.js b/react/src/components/dashboard/walletsNav/walletsNav.render.js index ddb32e5..e16a91e 100644 --- a/react/src/components/dashboard/walletsNav/walletsNav.render.js +++ b/react/src/components/dashboard/walletsNav/walletsNav.render.js @@ -41,7 +41,7 @@ export const WalletsNavWithWalletRender = function() { { this.props.ActiveCoin.mode === 'native' && @@ -60,7 +60,7 @@ export const WalletsNavWithWalletRender = function() {