Browse Source

chore(qr): add unconditional debug panel and simplify onInit for event binding test

- Add always-visible debug panel to QRScannerDialog to confirm template updates
- Simplify onInit signature and add alert to verify @init event is firing
- Refine error handling in onInit for clarity during debugging
pull/133/head
Matthew Raymer 3 weeks ago
parent
commit
7b7940189e
  1. 32
      src/components/QRScanner/QRScannerDialog.vue

32
src/components/QRScanner/QRScannerDialog.vue

@ -201,6 +201,10 @@
<div v-if="debugMessage" class="bg-yellow-200 text-black p-2 m-2 rounded"> <div v-if="debugMessage" class="bg-yellow-200 text-black p-2 m-2 rounded">
{{ debugMessage }} {{ debugMessage }}
</div> </div>
<div class="bg-red-200 text-black p-2 m-2 rounded">
DEBUG PANEL: If you see this, the template is updating.
</div>
</div> </div>
</div> </div>
</template> </template>
@ -278,9 +282,9 @@ export default class QRScannerDialog extends Vue {
} }
} }
async onInit(promise: Promise<void>, attempt = 1): Promise<void> { async onInit(promise: Promise<void>) {
alert("onInit called, attempt: " + attempt); alert("onInit called");
this.debugMessage = "onInit called, attempt: " + attempt; this.debugMessage = "onInit called";
let timeoutHit = false; let timeoutHit = false;
const timeout = setTimeout(() => { const timeout = setTimeout(() => {
timeoutHit = true; timeoutHit = true;
@ -304,25 +308,19 @@ export default class QRScannerDialog extends Vue {
clearTimeout(timeout); clearTimeout(timeout);
alert("Promise rejected: " + (error instanceof Error ? error.message : error)); alert("Promise rejected: " + (error instanceof Error ? error.message : error));
this.debugMessage = "Promise rejected: " + (error instanceof Error ? error.message : error); this.debugMessage = "Promise rejected: " + (error instanceof Error ? error.message : error);
if (attempt < 3) { if (error instanceof Error) {
// Retry after a short delay this.error = error.message;
setTimeout(() => this.onInit(promise, attempt + 1), 1500);
this.initializationStatus = `Retrying camera initialization (attempt ${attempt + 1})...`;
return;
}
const wrappedError =
error instanceof Error ? error : new Error(String(error));
this.error = wrappedError.message;
this.cameraStatus = "Error"; this.cameraStatus = "Error";
if (this.onError) { if (this.onError) {
this.onError(wrappedError); this.onError(error);
} }
logger.error("Error initializing QR scanner:", { logger.error("Error initializing QR scanner:", {
error: wrappedError.message, error: error.message,
stack: wrappedError.stack, stack: error.stack,
name: wrappedError.name, name: error.name,
type: wrappedError.constructor.name, type: error.constructor.name,
}); });
}
} finally { } finally {
this.isInitializing = false; this.isInitializing = false;
} }

Loading…
Cancel
Save