mirror of
https://github.com/BlueWallet/BlueWallet.git
synced 2025-03-04 04:13:49 +01:00
FIX: weird import screen scan qr code behaviour
This commit is contained in:
parent
b256f2d4f8
commit
bdcc40c8e0
6 changed files with 24 additions and 7 deletions
|
@ -2088,7 +2088,7 @@ export class BlueAddressInput extends Component {
|
||||||
<TouchableOpacity
|
<TouchableOpacity
|
||||||
disabled={this.props.isLoading}
|
disabled={this.props.isLoading}
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
NavigationService.navigate('ScanQrAddress', { onBarScanned: this.props.onBarScanned, launchedBy: this.props.launchedBy });
|
NavigationService.navigate('ScanQRCode', { onBarScanned: this.props.onBarScanned, launchedBy: this.props.launchedBy });
|
||||||
Keyboard.dismiss();
|
Keyboard.dismiss();
|
||||||
}}
|
}}
|
||||||
style={{
|
style={{
|
||||||
|
|
|
@ -35,7 +35,7 @@ import rbfCancel from './screen/transactions/RBFCancel';
|
||||||
import receiveDetails from './screen/receive/details';
|
import receiveDetails from './screen/receive/details';
|
||||||
|
|
||||||
import sendDetails from './screen/send/details';
|
import sendDetails from './screen/send/details';
|
||||||
import ScanQRCode from './screen/send/scanQrAddress';
|
import ScanQRCode from './screen/send/ScanQRCode';
|
||||||
import sendCreate from './screen/send/create';
|
import sendCreate from './screen/send/create';
|
||||||
import Confirm from './screen/send/confirm';
|
import Confirm from './screen/send/confirm';
|
||||||
import PsbtWithHardwareWallet from './screen/send/psbtWithHardwareWallet';
|
import PsbtWithHardwareWallet from './screen/send/psbtWithHardwareWallet';
|
||||||
|
@ -251,7 +251,7 @@ const HandleOffchainAndOnChainStackNavigator = createStackNavigator(
|
||||||
header: null,
|
header: null,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
ScanQrAddress: {
|
ScanQRCode: {
|
||||||
screen: ScanQRCode,
|
screen: ScanQRCode,
|
||||||
},
|
},
|
||||||
SendDetails: {
|
SendDetails: {
|
||||||
|
@ -322,7 +322,7 @@ const MainBottomTabs = createStackNavigator(
|
||||||
header: null,
|
header: null,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
ScanQrAddress: {
|
ScanQRCode: {
|
||||||
screen: ScanQRCode,
|
screen: ScanQRCode,
|
||||||
},
|
},
|
||||||
LappBrowser: {
|
LappBrowser: {
|
||||||
|
|
|
@ -209,7 +209,7 @@ export default class LNDCreateInvoice extends Component {
|
||||||
<TouchableOpacity
|
<TouchableOpacity
|
||||||
disabled={this.state.isLoading}
|
disabled={this.state.isLoading}
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
NavigationService.navigate('ScanQrAddress', {
|
NavigationService.navigate('ScanQRCode', {
|
||||||
onBarScanned: this.processLnurl,
|
onBarScanned: this.processLnurl,
|
||||||
launchedBy: this.props.navigation.state.routeName,
|
launchedBy: this.props.navigation.state.routeName,
|
||||||
});
|
});
|
||||||
|
|
|
@ -9,6 +9,7 @@ import { useNavigationParam, useNavigation } from 'react-navigation-hooks';
|
||||||
import DocumentPicker from 'react-native-document-picker';
|
import DocumentPicker from 'react-native-document-picker';
|
||||||
import RNFS from 'react-native-fs';
|
import RNFS from 'react-native-fs';
|
||||||
const LocalQRCode = require('@remobile/react-native-qrcode-local-image');
|
const LocalQRCode = require('@remobile/react-native-qrcode-local-image');
|
||||||
|
const createHash = require('create-hash');
|
||||||
|
|
||||||
const ScanQRCode = ({
|
const ScanQRCode = ({
|
||||||
onBarScanned = useNavigationParam('onBarScanned'),
|
onBarScanned = useNavigationParam('onBarScanned'),
|
||||||
|
@ -21,7 +22,23 @@ const ScanQRCode = ({
|
||||||
const [isLoading, setIsLoading] = useState(false);
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
const { navigate, goBack } = useNavigation();
|
const { navigate, goBack } = useNavigation();
|
||||||
|
|
||||||
|
const scannedCache = {};
|
||||||
|
|
||||||
|
const HashIt = function(s) {
|
||||||
|
return createHash('sha256')
|
||||||
|
.update(s)
|
||||||
|
.digest()
|
||||||
|
.toString('hex');
|
||||||
|
};
|
||||||
|
|
||||||
const onBarCodeRead = ret => {
|
const onBarCodeRead = ret => {
|
||||||
|
const h = HashIt(ret.data);
|
||||||
|
if (scannedCache[h]) {
|
||||||
|
// this QR was already scanned by this ScanQRCode, lets prevent firing duplicate callbacks
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
scannedCache[h] = +new Date();
|
||||||
|
|
||||||
if (!isLoading && !cameraPreviewIsPaused) {
|
if (!isLoading && !cameraPreviewIsPaused) {
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
try {
|
try {
|
|
@ -120,7 +120,7 @@ const WalletsImport = () => {
|
||||||
<BlueButtonLink
|
<BlueButtonLink
|
||||||
title={loc.wallets.import.scan_qr}
|
title={loc.wallets.import.scan_qr}
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
navigate('ScanQrAddress', { launchedBy: 'ImportWallet', onBarScanned, showFileImportButton: true });
|
navigate('ScanQRCode', { launchedBy: 'ImportWallet', onBarScanned, showFileImportButton: true });
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
|
|
|
@ -19,7 +19,7 @@ import PropTypes from 'prop-types';
|
||||||
import { PlaceholderWallet } from '../../class';
|
import { PlaceholderWallet } from '../../class';
|
||||||
import WalletImport from '../../class/walletImport';
|
import WalletImport from '../../class/walletImport';
|
||||||
import Swiper from 'react-native-swiper';
|
import Swiper from 'react-native-swiper';
|
||||||
import ScanQRCode from '../send/scanQrAddress';
|
import ScanQRCode from '../send/ScanQRCode';
|
||||||
import DeeplinkSchemaMatch from '../../class/deeplinkSchemaMatch';
|
import DeeplinkSchemaMatch from '../../class/deeplinkSchemaMatch';
|
||||||
let EV = require('../../events');
|
let EV = require('../../events');
|
||||||
let A = require('../../analytics');
|
let A = require('../../analytics');
|
||||||
|
|
Loading…
Add table
Reference in a new issue