avoid setting queue when tracklist is the same

This commit is contained in:
Thomas Amland
2020-10-03 20:35:46 +02:00
parent f3bdbbd44d
commit 554d58f04b
2 changed files with 18 additions and 2 deletions
+5 -2
View File
@@ -1,4 +1,5 @@
import { Store, Module } from 'vuex'
import { trackListEquals } from '@/shared/utils'
const audio = new Audio()
const storedQueue = JSON.parse(localStorage.getItem('queue') || '[]')
@@ -87,8 +88,10 @@ export const playerModule: Module<State, any> = {
},
actions: {
async playTrackList({ commit }, { queue, index }) {
commit('setQueue', [...queue])
async playTrackList({ commit, state }, { tracks, index }) {
if (!trackListEquals(state.queue, tracks)) {
commit('setQueue', [...tracks])
}
commit('setQueueIndex', index)
commit('setPlaying')
await audio.play()