Skip to content
Snippets Groups Projects
Commit cea1c147 authored by Agate's avatar Agate :speech_balloon:
Browse files

Fix #1190: improved shuffle behaviour

parent 191f28f7
No related branches found
No related tags found
No related merge requests found
Improved shuffle behaviour (#1190)
\ No newline at end of file
...@@ -158,16 +158,15 @@ export default { ...@@ -158,16 +158,15 @@ export default {
// so we replay automatically on next track append // so we replay automatically on next track append
commit('ended', true) commit('ended', true)
}, },
shuffle ({dispatch, commit, state}, callback) { async shuffle ({dispatch, commit, state}, callback) {
let toKeep = state.tracks.slice(0, state.currentIndex + 1) let shuffled = _.shuffle(state.tracks)
let toShuffle = state.tracks.slice(state.currentIndex + 1)
let shuffled = toKeep.concat(_.shuffle(toShuffle))
commit('tracks', []) commit('tracks', [])
let params = {tracks: shuffled} let params = {tracks: shuffled}
if (callback) { if (callback) {
params.callback = callback params.callback = callback
} }
dispatch('appendMany', params) await dispatch('appendMany', params)
await dispatch('currentIndex', 0)
} }
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment