perf: move init loops to player store
All checks were successful
repod / xml (push) Successful in 27s
repod / php (push) Successful in 41s
repod / nodejs (push) Successful in 1m21s
repod / release (push) Successful in 1m23s

This commit is contained in:
Michel Roux 2024-10-24 00:46:04 +02:00
parent 3aa5a6020e
commit 668c377c33
2 changed files with 9 additions and 9 deletions

View File

@ -33,15 +33,9 @@ export default {
}, },
mounted() { mounted() {
this.init() this.init()
setInterval(this.loop, 40000)
}, },
methods: { methods: {
...mapActions(usePlayer, ['init', 'time']), ...mapActions(usePlayer, ['init']),
loop() {
if (this.paused === false) {
this.time()
}
},
}, },
} }
</script> </script>

View File

@ -33,9 +33,15 @@ export const usePlayer = defineStore('player', {
audio.ontimeupdate = () => (this.currentTime = audio.currentTime) audio.ontimeupdate = () => (this.currentTime = audio.currentTime)
audio.onvolumechange = () => (this.volume = audio.volume) audio.onvolumechange = () => (this.volume = audio.volume)
setInterval(this.loop, 1000) setInterval(this.act, 40000)
setInterval(this.conflict, 1000)
}, },
loop() { act() {
if (this.paused === false) {
this.time()
}
},
conflict() {
this.playCount = 0 this.playCount = 0
}, },
async load(episode: EpisodeInterface | null, podcastUrl?: string) { async load(episode: EpisodeInterface | null, podcastUrl?: string) {