Resolve "Removing last track in queue jumps player to new last track (instead of continuing current track) (#1485)"
This commit is contained in:
parent
6adae1de66
commit
0cf83f3000
|
@ -0,0 +1 @@
|
||||||
|
Fixed before last track starts playing when last track removed (#1485)
|
|
@ -97,18 +97,18 @@ export default {
|
||||||
|
|
||||||
cleanTrack ({state, dispatch, commit}, index) {
|
cleanTrack ({state, dispatch, commit}, index) {
|
||||||
// are we removing current playin track
|
// are we removing current playin track
|
||||||
let current = index === state.currentIndex
|
const current = index === state.currentIndex
|
||||||
if (current) {
|
if (current) {
|
||||||
dispatch('player/stop', null, {root: true})
|
dispatch('player/stop', null, {root: true})
|
||||||
}
|
}
|
||||||
commit('splice', {start: index, size: 1})
|
commit('splice', {start: index, size: 1})
|
||||||
if (index < state.currentIndex) {
|
if (index < state.currentIndex) {
|
||||||
commit('currentIndex', state.currentIndex - 1)
|
commit('currentIndex', state.currentIndex - 1)
|
||||||
} else if (index > 0 && index === state.tracks.length) {
|
} else if (index > 0 && index === state.tracks.length && current) {
|
||||||
// kind of a edge case: if you delete the last track of the queue
|
// kind of a edge case: if you delete the last track of the queue
|
||||||
// we set current index to the previous one to avoid the queue tab from
|
// while it's playing we set current index to the previous one to
|
||||||
// being stuck because the player disappeared
|
// avoid the queue tab from being stuck because the player
|
||||||
// cf #1092
|
// disappeared cf #1092
|
||||||
commit('currentIndex', state.tracks.length - 1)
|
commit('currentIndex', state.tracks.length - 1)
|
||||||
} else if (current) {
|
} else if (current) {
|
||||||
// we play next track, which now have the same index
|
// we play next track, which now have the same index
|
||||||
|
|
|
@ -164,6 +164,20 @@ describe('store/queue', () => {
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
it('cleanTrack current is last', () => {
|
||||||
|
testAction({
|
||||||
|
action: store.actions.cleanTrack,
|
||||||
|
payload: 5,
|
||||||
|
params: { state: { currentIndex: 5, tracks: [1, 2, 3, 4, 5] } },
|
||||||
|
expectedMutations: [
|
||||||
|
{ type: 'splice', payload: { start: 5, size: 1 } },
|
||||||
|
{ type: 'currentIndex', payload: 4 }
|
||||||
|
],
|
||||||
|
expectedActions: [
|
||||||
|
{ type: 'player/stop', payload: null, options: { root: true } }
|
||||||
|
]
|
||||||
|
})
|
||||||
|
})
|
||||||
it('previous when at beginning', () => {
|
it('previous when at beginning', () => {
|
||||||
testAction({
|
testAction({
|
||||||
action: store.actions.previous,
|
action: store.actions.previous,
|
||||||
|
|
Loading…
Reference in New Issue