Unverified Commit b6a183f6 authored by Agate's avatar Agate 💬

Fix #1092: Ensure player doesn't disappear when last queue track is removed manually

parent 1638a319
Ensure player doesn't disappear when last queue track is removed manually (#1092)
......@@ -104,8 +104,13 @@ export default {
commit('splice', {start: index, size: 1})
if (index < state.currentIndex) {
commit('currentIndex', state.currentIndex - 1)
}
if (current) {
} else if (index > 0 && index === state.tracks.length) {
// 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
commit('currentIndex', state.tracks.length - 1)
} else if (current) {
// we play next track, which now have the same index
commit('currentIndex', index)
}
......
......@@ -133,7 +133,7 @@ describe('store/queue', () => {
testAction({
action: store.actions.cleanTrack,
payload: 3,
params: {state: {currentIndex: 2, tracks: []}},
params: {state: {currentIndex: 2, tracks: [1, 2, 3, 4, 5]}},
expectedMutations: [
{ type: 'splice', payload: {start: 3, size: 1} }
]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment