diff --git a/changes/changelog.d/209.bugfix b/changes/changelog.d/209.bugfix new file mode 100644 index 0000000000000000000000000000000000000000..00605735f154ae9b3e29c75d1f22ac27179758a4 --- /dev/null +++ b/changes/changelog.d/209.bugfix @@ -0,0 +1 @@ +Fixed skipped track when appending multiple tracks to the queue under certain conditions (#209) diff --git a/front/src/store/queue.js b/front/src/store/queue.js index 81403b11fa6d77d2e5332a77ed12ba3023d3f00e..2020fd0ba3f20f3e2bf610e28f9d929f7bb5e6d2 100644 --- a/front/src/store/queue.js +++ b/front/src/store/queue.js @@ -59,7 +59,7 @@ export default { isEmpty: state => state.tracks.length === 0 }, actions: { - append ({commit, state, dispatch}, {track, index, skipPlay}) { + append ({commit, state, dispatch}, {track, index}) { index = index || state.tracks.length if (index > state.tracks.length - 1) { // we simply push to the end @@ -68,9 +68,6 @@ export default { // we insert the track at given position commit('insert', {track, index}) } - if (!skipPlay) { - dispatch('resume') - } }, appendMany ({state, dispatch}, {tracks, index, callback}) { @@ -82,13 +79,12 @@ export default { } let total = tracks.length tracks.forEach((t, i) => { - let p = dispatch('append', {track: t, index: index, skipPlay: true}) + let p = dispatch('append', {track: t, index: index}) index += 1 if (callback && i + 1 === total) { p.then(callback) } }) - dispatch('resume') }, cleanTrack ({state, dispatch, commit}, index) { @@ -110,11 +106,6 @@ export default { } }, - resume ({state, dispatch, rootState}) { - if (state.ended | rootState.player.errored) { - dispatch('next') - } - }, previous ({state, dispatch, rootState}) { if (state.currentIndex > 0 && rootState.player.currentTime < 3) { dispatch('currentIndex', state.currentIndex - 1) diff --git a/front/tests/unit/specs/store/queue.spec.js b/front/tests/unit/specs/store/queue.spec.js index 282a4f02633758d878f7a89106844b6981fcccfd..3fa481d1931a94b596bb09429e695711f4bb85eb 100644 --- a/front/tests/unit/specs/store/queue.spec.js +++ b/front/tests/unit/specs/store/queue.spec.js @@ -88,7 +88,7 @@ describe('store/queue', () => { it('append at end', () => { testAction({ action: store.actions.append, - payload: {track: 4, skipPlay: true}, + payload: {track: 4}, params: {state: {tracks: [1, 2, 3]}}, expectedMutations: [ { type: 'insert', payload: {track: 4, index: 3} } @@ -98,26 +98,13 @@ describe('store/queue', () => { it('append at index', () => { testAction({ action: store.actions.append, - payload: {track: 2, index: 1, skipPlay: true}, + payload: {track: 2, index: 1}, params: {state: {tracks: [1, 3]}}, expectedMutations: [ { type: 'insert', payload: {track: 2, index: 1} } ] }) }) - it('append and play', () => { - testAction({ - action: store.actions.append, - payload: {track: 3}, - params: {state: {tracks: [1, 2]}}, - expectedMutations: [ - { type: 'insert', payload: {track: 3, index: 2} } - ], - expectedActions: [ - { type: 'resume' } - ] - }) - }) it('appendMany', () => { const tracks = [{title: 1}, {title: 2}] testAction({ @@ -125,9 +112,8 @@ describe('store/queue', () => { payload: {tracks: tracks}, params: {state: {tracks: []}}, expectedActions: [ - { type: 'append', payload: {track: tracks[0], index: 0, skipPlay: true} }, - { type: 'append', payload: {track: tracks[1], index: 1, skipPlay: true} }, - { type: 'resume' } + { type: 'append', payload: {track: tracks[0], index: 0} }, + { type: 'append', payload: {track: tracks[1], index: 1} }, ] }) }) @@ -138,9 +124,8 @@ describe('store/queue', () => { payload: {tracks: tracks, index: 1}, params: {state: {tracks: [1, 2]}}, expectedActions: [ - { type: 'append', payload: {track: tracks[0], index: 1, skipPlay: true} }, - { type: 'append', payload: {track: tracks[1], index: 2, skipPlay: true} }, - { type: 'resume' } + { type: 'append', payload: {track: tracks[0], index: 1} }, + { type: 'append', payload: {track: tracks[1], index: 2} }, ] }) }) @@ -179,31 +164,6 @@ describe('store/queue', () => { ] }) }) - it('resume when ended', () => { - testAction({ - action: store.actions.resume, - params: {state: {ended: true}, rootState: {player: {errored: false}}}, - expectedActions: [ - { type: 'next' } - ] - }) - }) - it('resume when errored', () => { - testAction({ - action: store.actions.resume, - params: {state: {ended: false}, rootState: {player: {errored: true}}}, - expectedActions: [ - { type: 'next' } - ] - }) - }) - it('skip resume when not ended or not error', () => { - testAction({ - action: store.actions.resume, - params: {state: {ended: false}, rootState: {player: {errored: false}}}, - expectedActions: [] - }) - }) it('previous when at beginning', () => { testAction({ action: store.actions.previous,