diff --git a/changes/changelog.d/1092.bugfix b/changes/changelog.d/1092.bugfix new file mode 100644 index 0000000000000000000000000000000000000000..018470ac801681bdeaf4aa1fb04516195f2876d9 --- /dev/null +++ b/changes/changelog.d/1092.bugfix @@ -0,0 +1 @@ +Ensure player doesn't disappear when last queue track is removed manually (#1092) diff --git a/front/src/store/queue.js b/front/src/store/queue.js index 5514db92109c9ba56a347283b4a2262c5e9c0ef3..a5ab856a44d8088a4b3c0c986f0ab65a845c474a 100644 --- a/front/src/store/queue.js +++ b/front/src/store/queue.js @@ -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) } diff --git a/front/tests/unit/specs/store/queue.spec.js b/front/tests/unit/specs/store/queue.spec.js index afdf46c905e4c3bbb94f8f32ad250aa8e62c1c0d..f690982468cea2ae7f6cb80125d1b30268806d02 100644 --- a/front/tests/unit/specs/store/queue.spec.js +++ b/front/tests/unit/specs/store/queue.spec.js @@ -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} } ]