1
0
Fork 0
mirror of https://gitlab.com/futo-org/fcast.git synced 2025-06-24 21:25:23 +00:00

Fixed loading screen race condition

This commit is contained in:
Michael Hollister 2025-02-19 01:51:18 -06:00
parent 98962984c6
commit 5c071fb202

View file

@ -8,20 +8,25 @@ const loadingScreen = document.getElementById('loading-screen');
var backgroundVideoLoaded: boolean; var backgroundVideoLoaded: boolean;
// eslint-disable-next-line no-var // eslint-disable-next-line no-var
var qrCodeRendered: boolean; var qrCodeRendered: boolean;
// eslint-disable-next-line no-var
var loadPollCount = 0;
// eslint-disable-next-line no-var
var loadScreenDone = setInterval(() => {
// Show main screen regardless if resources not loaded within 10s
if ((backgroundVideoLoaded && qrCodeRendered) || loadPollCount > 10) {
clearInterval(loadScreenDone);
loadingScreen.style.display = 'none';
}
loadPollCount++;
}, 1000);
backgroundVideo.onplaying = () => { backgroundVideo.onplaying = () => {
backgroundVideoLoaded = true; backgroundVideoLoaded = true;
backgroundVideo.onplaying = null;
if (backgroundVideoLoaded && qrCodeRendered) {
loadingScreen.style.display = 'none';
backgroundVideo.onplaying = null;
}
}; };
export function onQRCodeRendered() { export function onQRCodeRendered() {
qrCodeRendered = true; qrCodeRendered = true;
if (backgroundVideoLoaded && qrCodeRendered) {
loadingScreen.style.display = 'none';
}
} }