codex/add-barcode-scan-to-item #6
@@ -784,6 +784,9 @@ export function labelCreatePageData(store) {
|
|||||||
|
|
||||||
this.stopScanner();
|
this.stopScanner();
|
||||||
this.scannerState.isLoading = true;
|
this.scannerState.isLoading = true;
|
||||||
|
const shouldLogDecodeErrors = import.meta.env.DEV;
|
||||||
|
let lastDecodeErrorName = '';
|
||||||
|
let lastDecodeErrorAt = 0;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (!this.scannerReader) {
|
if (!this.scannerReader) {
|
||||||
@@ -804,13 +807,20 @@ export function labelCreatePageData(store) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!error || error?.name === 'NotFoundException') {
|
if (error) {
|
||||||
|
// Continuous decode emits expected per-frame misses/errors before a valid barcode is found.
|
||||||
|
// Keep the modal quiet and only surface startup failures from the outer catch block.
|
||||||
|
if (shouldLogDecodeErrors) {
|
||||||
|
const errorName = String(error?.name || 'UnknownError');
|
||||||
|
const now = Date.now();
|
||||||
|
if (errorName !== lastDecodeErrorName || now - lastDecodeErrorAt > 2000) {
|
||||||
|
console.debug('[scanner] Ignoring frame decode error while scanning:', errorName, error?.message || '');
|
||||||
|
lastDecodeErrorName = errorName;
|
||||||
|
lastDecodeErrorAt = now;
|
||||||
|
}
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.scannerState.error) {
|
|
||||||
this.scannerState.error = this.normalizeScannerError(error);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
@@ -470,6 +470,9 @@ export function stockDetailPageData(store) {
|
|||||||
|
|
||||||
this.stopScanner();
|
this.stopScanner();
|
||||||
this.scannerState.isLoading = true;
|
this.scannerState.isLoading = true;
|
||||||
|
const shouldLogDecodeErrors = import.meta.env.DEV;
|
||||||
|
let lastDecodeErrorName = '';
|
||||||
|
let lastDecodeErrorAt = 0;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (!this.scannerReader) {
|
if (!this.scannerReader) {
|
||||||
@@ -490,13 +493,20 @@ export function stockDetailPageData(store) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!error || error?.name === 'NotFoundException') {
|
if (error) {
|
||||||
|
// Continuous decode emits expected per-frame misses/errors before a valid barcode is found.
|
||||||
|
// Keep the modal quiet and only surface startup failures from the outer catch block.
|
||||||
|
if (shouldLogDecodeErrors) {
|
||||||
|
const errorName = String(error?.name || 'UnknownError');
|
||||||
|
const now = Date.now();
|
||||||
|
if (errorName !== lastDecodeErrorName || now - lastDecodeErrorAt > 2000) {
|
||||||
|
console.debug('[scanner] Ignoring frame decode error while scanning:', errorName, error?.message || '');
|
||||||
|
lastDecodeErrorName = errorName;
|
||||||
|
lastDecodeErrorAt = now;
|
||||||
|
}
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.scannerState.error) {
|
|
||||||
this.scannerState.error = this.normalizeScannerError(error);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
Reference in New Issue
Block a user