Hopefully this works... QR stop and start?

This commit is contained in:
2024-04-09 23:05:32 -04:00
parent f68bccddb9
commit a51e96ea6e
3 changed files with 64 additions and 27 deletions

View File

@@ -161,9 +161,20 @@ function handle_start_qr_scanning() {
.then((ignore: any) => {
console.log('Scanning has started');
scanning_status = 'scanning';
// let subject = 'QR Scanning Started';
// let message = ignore;
// send_init_confirm_email(subject, message);
return true;
}).catch((err) => {
console.log('There was an error while trying to start the QR scanner');
scanning_status = 'start_error';
let subject = 'QR Scanning Start Error';
let message = err;
send_init_confirm_email(subject, message);
return false;
});
}
@@ -192,27 +203,47 @@ function handle_resume_qr_scanning() {
async function handle_stop_qr_scanning() {
if (html5_qr_code && html5_qr_code.getState() == Html5QrcodeScannerState.NOT_STARTED) {
start_qr_scanner = false;
if (!html5_qr_code) {
console.log('html5_qr_code object found. Nothing to stop?');
return false;
}
let state = html5_qr_code.getState();
console.log('html5_qr_code state:', state);
if (state == Html5QrcodeScannerState.NOT_STARTED) {
console.log('Scanner is not started');
return;
}
if (state == Html5QrcodeScannerState.PAUSED || state == Html5QrcodeScannerState.SCANNING) {
console.log('Scanner is not started');
await html5_qr_code.stop()
scanning_status = 'not_started';
return;
}
await html5_qr_code.clear();
return true;
// html5_qr_code.pause();
await html5_qr_code.stop().then((ignore) => {
console.log('Scanning has stopped');
// document.getElementById('qr_scanner_viewfinder').classList.add('d_none');
scanning_status = 'not_started';
}).then((ignore) => {
// html5_qr_code = null;
html5_qr_code.clear();
}).catch((err) => {
console.log('There was an error while trying to stop the scanning');
return false;
});
// return html5_qr_code.stop()
// .then((ignore) => {
// console.log('Scanning has stopped');
// // document.getElementById('qr_scanner_viewfinder').classList.add('d_none');
// scanning_status = 'not_started';
// }).then((ignore) => {
// // html5_qr_code = null;
// // html5_qr_code.clear();
// }).catch((err) => {
// console.log('There was an error while trying to stop the scanning');
// return false;
// });
// html5_qr_code = null;
return;
}