Skip to content
Snippets Groups Projects
Commit 0cf83f30 authored by Marcos Peña's avatar Marcos Peña Committed by JuniorJPDJ
Browse files

Resolve "Removing last track in queue jumps player to new last track (instead...

Resolve "Removing last track in queue jumps player to new last track (instead of continuing current track) (#1485)" 
parent 6adae1de
No related branches found
No related tags found
No related merge requests found
Fixed before last track starts playing when last track removed (#1485)
......@@ -97,18 +97,18 @@ export default {
cleanTrack ({state, dispatch, commit}, index) {
// are we removing current playin track
let current = index === state.currentIndex
const current = index === state.currentIndex
if (current) {
dispatch('player/stop', null, {root: true})
}
commit('splice', {start: index, size: 1})
if (index < state.currentIndex) {
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
// we set current index to the previous one to avoid the queue tab from
// being stuck because the player disappeared
// cf #1092
// while it's playing we set current index to the previous one to
// avoid the queue tab from being stuck because the player
// disappeared cf #1092
commit('currentIndex', state.tracks.length - 1)
} else if (current) {
// 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', () => {
testAction({
action: store.actions.previous,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment