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">
|
<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.cameraStatus = "Error";
|
||||||
this.initializationStatus = `Retrying camera initialization (attempt ${attempt + 1})...`;
|
if (this.onError) {
|
||||||
return;
|
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 {
|
} finally {
|
||||||
this.isInitializing = false;
|
this.isInitializing = false;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user