From b673a7a7fc66f1582ddb7cd94b32548a58a87670 Mon Sep 17 00:00:00 2001 From: brunobar79 Date: Mon, 30 Jul 2018 18:40:00 -0400 Subject: [PATCH] kill camera stream when unmouting --- ui/app/components/modals/qr-scanner/qr-scanner.component.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ui/app/components/modals/qr-scanner/qr-scanner.component.js b/ui/app/components/modals/qr-scanner/qr-scanner.component.js index 998967776..580774635 100644 --- a/ui/app/components/modals/qr-scanner/qr-scanner.component.js +++ b/ui/app/components/modals/qr-scanner/qr-scanner.component.js @@ -33,6 +33,10 @@ export default class QrScanner extends Component { } } + componentWillUnmount () { + this.codeReader.reset() + } + initCamera () { console.log('[QR-SCANNER]: initCamera') this.codeReader = new BrowserQRCodeReader() @@ -50,7 +54,6 @@ export default class QrScanner extends Component { this.codeReader.decodeFromInputVideoDevice(videoInputDevices[0].deviceId, 'video') .then(content => { console.log('[QR-SCANNER]: initCamera::decodeFromInputVideoDevice callback', content) - this.codeReader.reset() const result = this.parseContent(content.text) if (result.type !== 'unknown') { this.props.qrCodeDetected(result)