Merge branch '209-album-play-first-bis' into 'develop'
Fix #209: skipped track when appending multiple tracks to the queue under certain conditions (#209) Closes #209 See merge request funkwhale/funkwhale!476
This commit is contained in:
commit
f07d696445
|
@ -0,0 +1 @@
|
|||
Fixed skipped track when appending multiple tracks to the queue under certain conditions (#209)
|
|
@ -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)
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue