Fixed #151: queue reorder or track deletion restarting currently playing track

This commit is contained in:
Eliot Berriot 2018-04-23 18:32:27 +02:00
parent 48c9a8bd55
commit 6ed6634f93
No known key found for this signature in database
GPG Key ID: DD6965E2476E5C27
6 changed files with 15 additions and 9 deletions

View File

@ -0,0 +1 @@
Fixed queue reorder or track deletion restarting currently playing track (#151)

View File

@ -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]

View File

@ -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"

View File

@ -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) {

View File

@ -92,10 +92,10 @@ export default {
if (current) { if (current) {
dispatch('player/stop', null, {root: true}) dispatch('player/stop', null, {root: true})
} }
if (index < state.currentIndex) {
dispatch('currentIndex', state.currentIndex - 1)
}
commit('splice', {start: index, size: 1}) commit('splice', {start: index, size: 1})
if (index < state.currentIndex) {
commit('currentIndex', state.currentIndex - 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)

View File

@ -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)