diff --git a/src/static/js/synced-timer.js b/src/static/js/synced-timer.js index 98b3095..0e16843 100644 --- a/src/static/js/synced-timer.js +++ b/src/static/js/synced-timer.js @@ -47,8 +47,10 @@ document.addEventListener('alpine:init', () => { scheduleNextRequest() { setTimeout(() => { let requestUrl; + // Clear timings to avoid overflow + performance.clearResourceTimings(); // Add a request Id to be able to identify this request later on - fetch(`/api/${username}?id=${parseInt(performance.now())}`) + fetch(`/api/${username}?id=${parseInt(performance.now()) % 10000}`) .then((response) => { requestUrl = response.url return response.json() @@ -119,10 +121,6 @@ document.addEventListener('alpine:init', () => { this.audioPlayer.play().then(() => { this.isAvailable = true this.hasBeenTested = true - - this.preloadSound(this.sounds.beep) - this.preloadSound(this.sounds.countdown) - }).catch((error) => { console.warn("Audio permission not granted!") this.isAvailable = false @@ -134,7 +132,7 @@ document.addEventListener('alpine:init', () => { if (!this.audioPlayer.paused || !this.isAvailable || this.isDisabledByUser || this.isDisabledByServer || this.replayLocked) { return; } - if (this.audioPlayer.src !== soundFile) { + if (!this.audioPlayer.src.endsWith(soundFile)) { this.audioPlayer.src = soundFile; } this.replayLocked = true; @@ -142,7 +140,7 @@ document.addEventListener('alpine:init', () => { }, preloadSound(soundFile) { - if (this.audioPlayer.src === soundFile) { + if (this.audioPlayer.src.endsWith(soundFile)) { return; } console.log(`Preloading sound ${soundFile}`)