Hopefully this works... QR stop and start?
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ let lq__event_badge_li = liveQuery(
|
||||
let ae_promises: key_val = {};
|
||||
let load_obj_li_results: Promise<any>|key_val;
|
||||
let search_submit_results: Promise<any>|key_val;
|
||||
let scan_submit_results: Promise<any>|key_val;
|
||||
// let scan_submit_results: Promise<any>|key_val;
|
||||
|
||||
|
||||
$ae_loc.hostname = data.url.hostname;
|
||||
|
||||
@@ -216,7 +216,6 @@ function handle_qr_camera(event) {
|
||||
$events_sess.leads.show_form__scan = true;
|
||||
$events_sess.leads.qr_scan_start = true;
|
||||
}}
|
||||
disabled={!$ae_loc.trusted_access && 2==4}
|
||||
title="Scan a QR code to add a person to the leads list."
|
||||
>
|
||||
<span class="fas fa-qrcode mx-1"></span>
|
||||
@@ -663,7 +662,13 @@ function handle_qr_camera(event) {
|
||||
|
||||
|
||||
<!-- <div class=""> -->
|
||||
<Element_qr_scanner start_qr_scanner={$events_sess.leads.qr_scan_start} show_qr_scan_result={true} show_qr_manual_badge_id_entry_option={true} on:qr_scan_result={handle_qr_scan_result} on:qr_camera={handle_qr_camera} />
|
||||
<Element_qr_scanner
|
||||
start_qr_scanner={$events_sess.leads.qr_scan_start}
|
||||
show_qr_scan_result={true}
|
||||
show_qr_manual_badge_id_entry_option={true}
|
||||
on:qr_scan_result={handle_qr_scan_result}
|
||||
on:qr_camera={handle_qr_camera}
|
||||
/>
|
||||
<!-- </div> -->
|
||||
|
||||
<div class="qr_quick_results variant-soft-secondary font-bold p-4">
|
||||
@@ -794,25 +799,26 @@ function handle_qr_camera(event) {
|
||||
</section> <!-- .popover__content -->
|
||||
|
||||
<footer class="popover__footer flex gap-1 justify-between items-center p-1 border-t">
|
||||
<div class="popover__content__actions">
|
||||
<!-- <div class="popover__content__actions">
|
||||
<button
|
||||
type="submit"
|
||||
form="form__scan_text"
|
||||
type="button"
|
||||
class="btn variant-soft-primary"
|
||||
disabled={scan_submit_results instanceof Promise && !scan_submit_results}
|
||||
on:click={() => {
|
||||
// trigger = 'save__ds__code';
|
||||
// $slct_trigger = 'save__ds__code';
|
||||
$events_sess.leads.qr_scan_start = !$events_sess.leads.qr_scan_start;
|
||||
}}
|
||||
>
|
||||
<span class="fas fa-search mx-1"></span>
|
||||
Scan
|
||||
{#if $events_sess.leads.qr_scan_start}
|
||||
Stop Scanning
|
||||
{:else}
|
||||
Scanning
|
||||
{/if}
|
||||
</button>
|
||||
</div>
|
||||
</div> -->
|
||||
|
||||
<div class="popover__status">
|
||||
<!-- Something text -->
|
||||
{#await scan_submit_results}
|
||||
<!-- {#await scan_submit_results}
|
||||
<div class="modal-loading">
|
||||
<span class="fas fa-spinner fa-spin"></span>
|
||||
<span class="loading-text">
|
||||
@@ -829,7 +835,7 @@ function handle_qr_camera(event) {
|
||||
</span>
|
||||
</div>
|
||||
{/if}
|
||||
{/await}
|
||||
{/await} -->
|
||||
|
||||
<div
|
||||
class="ae_debug"
|
||||
@@ -844,8 +850,8 @@ function handle_qr_camera(event) {
|
||||
type="button"
|
||||
class="btn variant-soft-primary"
|
||||
on:click={() => {
|
||||
|
||||
$events_sess.leads.show_form__scan = false;
|
||||
$events_sess.leads.qr_scan_start = false;
|
||||
}}
|
||||
>
|
||||
<span class="fas fa-times mx-1"></span>
|
||||
|
||||
Reference in New Issue
Block a user