forked from trent_larson/crowd-funder-for-time-pwa
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
This commit is contained in:
@@ -201,6 +201,10 @@
|
||||
<div v-if="debugMessage" class="bg-yellow-200 text-black p-2 m-2 rounded">
|
||||
{{ debugMessage }}
|
||||
</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>
|
||||
</template>
|
||||
@@ -278,9 +282,9 @@ export default class QRScannerDialog extends Vue {
|
||||
}
|
||||
}
|
||||
|
||||
async onInit(promise: Promise<void>, attempt = 1): Promise<void> {
|
||||
alert("onInit called, attempt: " + attempt);
|
||||
this.debugMessage = "onInit called, attempt: " + attempt;
|
||||
async onInit(promise: Promise<void>) {
|
||||
alert("onInit called");
|
||||
this.debugMessage = "onInit called";
|
||||
let timeoutHit = false;
|
||||
const timeout = setTimeout(() => {
|
||||
timeoutHit = true;
|
||||
@@ -304,25 +308,19 @@ export default class QRScannerDialog extends Vue {
|
||||
clearTimeout(timeout);
|
||||
alert("Promise rejected: " + (error instanceof Error ? error.message : error));
|
||||
this.debugMessage = "Promise rejected: " + (error instanceof Error ? error.message : error);
|
||||
if (attempt < 3) {
|
||||
// Retry after a short delay
|
||||
setTimeout(() => this.onInit(promise, attempt + 1), 1500);
|
||||
this.initializationStatus = `Retrying camera initialization (attempt ${attempt + 1})...`;
|
||||
return;
|
||||
if (error instanceof Error) {
|
||||
this.error = error.message;
|
||||
this.cameraStatus = "Error";
|
||||
if (this.onError) {
|
||||
this.onError(error);
|
||||
}
|
||||
logger.error("Error initializing QR scanner:", {
|
||||
error: error.message,
|
||||
stack: error.stack,
|
||||
name: error.name,
|
||||
type: error.constructor.name,
|
||||
});
|
||||
}
|
||||
const wrappedError =
|
||||
error instanceof Error ? error : new Error(String(error));
|
||||
this.error = wrappedError.message;
|
||||
this.cameraStatus = "Error";
|
||||
if (this.onError) {
|
||||
this.onError(wrappedError);
|
||||
}
|
||||
logger.error("Error initializing QR scanner:", {
|
||||
error: wrappedError.message,
|
||||
stack: wrappedError.stack,
|
||||
name: wrappedError.name,
|
||||
type: wrappedError.constructor.name,
|
||||
});
|
||||
} finally {
|
||||
this.isInitializing = false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user