Skip to content
Snippets Groups Projects
Commit af883242 authored by Eliot Berriot's avatar Eliot Berriot
Browse files

Merge branch '151-queue-delete' into 'develop'

Resolve "Reordering the queue do not honor currently playing track"

Closes #151

See merge request !158
parents 48c9a8bd 6ed6634f
No related branches found
No related tags found
No related merge requests found
Fixed queue reorder or track deletion restarting currently playing track (#151)
...@@ -143,8 +143,9 @@ export default { ...@@ -143,8 +143,9 @@ export default {
...mapActions({ ...mapActions({
cleanTrack: 'queue/cleanTrack' cleanTrack: 'queue/cleanTrack'
}), }),
reorder: function (oldValue, newValue) { reorder: function (event) {
this.$store.commit('queue/reorder', {oldValue, newValue}) this.$store.commit('queue/reorder', {
oldIndex: event.oldIndex, newIndex: event.newIndex})
}, },
scrollToCurrent () { scrollToCurrent () {
let current = $(this.$el).find('[data-tab="queue"] .active')[0] let current = $(this.$el).find('[data-tab="queue"] .active')[0]
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
<audio-track <audio-track
ref="currentAudio" ref="currentAudio"
v-if="renderAudio && currentTrack" v-if="renderAudio && currentTrack"
:key="(currentIndex, currentTrack.id)" :key="currentTrack.id"
:is-current="true" :is-current="true"
:start-time="$store.state.player.currentTime" :start-time="$store.state.player.currentTime"
:autoplay="$store.state.player.playing" :autoplay="$store.state.player.playing"
......
...@@ -86,9 +86,15 @@ export default { ...@@ -86,9 +86,15 @@ export default {
} }
}, },
updateDuration: function (e) { updateDuration: function (e) {
if (!this.$refs.audio) {
return
}
this.$store.commit('player/duration', this.$refs.audio.duration) this.$store.commit('player/duration', this.$refs.audio.duration)
}, },
loaded: function () { loaded: function () {
if (!this.$refs.audio) {
return
}
this.$refs.audio.volume = this.volume this.$refs.audio.volume = this.volume
this.$store.commit('player/resetErrorCount') this.$store.commit('player/resetErrorCount')
if (this.isCurrent) { if (this.isCurrent) {
......
...@@ -92,10 +92,10 @@ export default { ...@@ -92,10 +92,10 @@ export default {
if (current) { if (current) {
dispatch('player/stop', null, {root: true}) dispatch('player/stop', null, {root: true})
} }
commit('splice', {start: index, size: 1})
if (index < state.currentIndex) { if (index < state.currentIndex) {
dispatch('currentIndex', state.currentIndex - 1) commit('currentIndex', state.currentIndex - 1)
} }
commit('splice', {start: index, size: 1})
if (current) { if (current) {
// we play next track, which now have the same index // we play next track, which now have the same index
dispatch('currentIndex', index) dispatch('currentIndex', index)
......
...@@ -158,9 +158,7 @@ describe('store/queue', () => { ...@@ -158,9 +158,7 @@ describe('store/queue', () => {
payload: 1, payload: 1,
params: {state: {currentIndex: 2}}, params: {state: {currentIndex: 2}},
expectedMutations: [ expectedMutations: [
{ type: 'splice', payload: {start: 1, size: 1} } { type: 'splice', payload: {start: 1, size: 1} },
],
expectedActions: [
{ type: 'currentIndex', payload: 1 } { type: 'currentIndex', payload: 1 }
] ]
}, done) }, done)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment