forked from jsnbuchanan/crowd-funder-for-time-pwa
refactor(qr): improve QR code scanning robustness and error handling
- Enhance JWT extraction with unified path handling and validation - Add debouncing to prevent duplicate scans - Improve error handling and logging throughout QR flow - Add proper TypeScript interfaces for QR scan results - Implement mobile app lifecycle handlers (pause/resume) - Enhance logging with structured data and consistent levels - Clean up scanner resources properly on component destroy - Split contact handling into separate method for better organization - Add proper type for UserNameDialog ref This commit improves the reliability and maintainability of the QR code scanning functionality while adding better error handling and logging.
This commit is contained in:
@@ -92,9 +92,9 @@ interface ScanProps {
|
||||
},
|
||||
})
|
||||
export default class QRScannerDialog extends Vue {
|
||||
@Prop({ type: Function, required: true }) onScan!: ScanProps['onScan'];
|
||||
@Prop({ type: Function }) onError?: ScanProps['onError'];
|
||||
@Prop({ type: Object }) options?: ScanProps['options'];
|
||||
@Prop({ type: Function, required: true }) onScan!: ScanProps["onScan"];
|
||||
@Prop({ type: Function }) onError?: ScanProps["onError"];
|
||||
@Prop({ type: Object }) options?: ScanProps["options"];
|
||||
|
||||
visible = true;
|
||||
error: string | null = null;
|
||||
@@ -132,7 +132,8 @@ export default class QRScannerDialog extends Vue {
|
||||
await promise;
|
||||
this.error = null;
|
||||
} catch (error) {
|
||||
const wrappedError = error instanceof Error ? error : new Error(String(error));
|
||||
const wrappedError =
|
||||
error instanceof Error ? error : new Error(String(error));
|
||||
this.error = wrappedError.message;
|
||||
if (this.onError) {
|
||||
this.onError(wrappedError);
|
||||
@@ -146,7 +147,8 @@ export default class QRScannerDialog extends Vue {
|
||||
this.onScan(result);
|
||||
this.close();
|
||||
} catch (error) {
|
||||
const wrappedError = error instanceof Error ? error : new Error(String(error));
|
||||
const wrappedError =
|
||||
error instanceof Error ? error : new Error(String(error));
|
||||
this.error = wrappedError.message;
|
||||
if (this.onError) {
|
||||
this.onError(wrappedError);
|
||||
|
||||
Reference in New Issue
Block a user