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:
parent
98962984c6
commit
5c071fb202
1 changed files with 14 additions and 9 deletions
|
@ -8,20 +8,25 @@ const loadingScreen = document.getElementById('loading-screen');
|
|||
var backgroundVideoLoaded: boolean;
|
||||
// eslint-disable-next-line no-var
|
||||
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 = () => {
|
||||
backgroundVideoLoaded = true;
|
||||
|
||||
if (backgroundVideoLoaded && qrCodeRendered) {
|
||||
loadingScreen.style.display = 'none';
|
||||
backgroundVideo.onplaying = null;
|
||||
}
|
||||
};
|
||||
|
||||
export function onQRCodeRendered() {
|
||||
qrCodeRendered = true;
|
||||
|
||||
if (backgroundVideoLoaded && qrCodeRendered) {
|
||||
loadingScreen.style.display = 'none';
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue