1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00

Prevent unnecessary teardown

This commit is contained in:
David Walsh 2020-10-14 17:05:36 -05:00
parent 947bfb7a11
commit 15654b3d0b

View File

@ -119,10 +119,11 @@ export default class QrScanner extends Component {
// The `decodeFromInputVideoDevice` call prompts the browser to show // The `decodeFromInputVideoDevice` call prompts the browser to show
// the user the camera permission request. We must then call it again // the user the camera permission request. We must then call it again
// once we receive permission so that the video displays. // once we receive permission so that the video displays.
// Removing this teardown will create 2 video streams in Firefox, one // It's important to prevent this codeReader from being created twice;
// of which the user will not be able to remove without refreshing the page. // Firefox otherwise starts 2 video streams, one of which cannot be stopped
this.teardownCodeReader(); if(!this.codeReader) {
this.codeReader = new BrowserQRCodeReader() this.codeReader = new BrowserQRCodeReader()
}
try { try {
await this.codeReader.getVideoInputDevices() await this.codeReader.getVideoInputDevices()
this.checkPermissions(); this.checkPermissions();