Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
"libsodium-wrappers": "^0.8.4",
"mediabunny": "^1.46.0",
"prismjs": "^1.29.0",
"qr-code-styling": "^1.5.0",
"qr-code-styling": "1.9.2",
"rollup-plugin-visualizer": "^7.0.1",
"sass": "^1.98.0",
"solid-js": "1.9.9",
Expand Down
2 changes: 1 addition & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 5 additions & 16 deletions src/helpers/qrCode/paintQrCode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,22 +74,11 @@ export async function paintQrCode(options: PaintQrOptions) {
const canvas = host.lastChild as HTMLCanvasElement;
if (options.canvasClass) canvas.classList.add(options.canvasClass);

// qr-code-styling races the image-load against a 1s upper bound — matches the
// legacy behaviour so we don't leave the host stuck behind a never-loading logo.
let drawingPromise: Promise<void>;
if (qrCode._drawingPromise) {
drawingPromise = qrCode._drawingPromise;
} else {
drawingPromise = Promise.race([
pause(1000),
new Promise<void>((resolve) => {
qrCode._canvas._image.addEventListener('load', () => {
window.requestAnimationFrame(() => resolve());
}, { once: true });
}),
]);
}
await drawingPromise;
// qr-code-styling exposes `_canvasDrawingPromise`, which resolves once the SVG
// (logo image included) has been rasterized onto the canvas. Cap it with a 1s
// upper bound so a never-loading logo can't leave the host stuck behind a
// preloader, matching the legacy behaviour.
await Promise.race([pause(1000), qrCode._canvasDrawingPromise ?? Promise.resolve()]);

return { canvas, qrCode };
}
Expand Down
Loading