Fix: Overflow of performance entrys, unnecessary loading of sounds
This commit is contained in:
parent
cb03447971
commit
1db80aa45c
1 changed files with 5 additions and 7 deletions
|
@ -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}`)
|
||||
|
|
Loading…
Reference in a new issue