Verified Commit 5f28f7e9 authored by Eliot Berriot's avatar Eliot Berriot
Browse files

Fixed #87:Now always load next radio track on last queue track ended

parent fb8a6644
......@@ -78,8 +78,15 @@ export default {
logger.default.error('Could not record track in history')
})
},
trackEnded ({dispatch}, track) {
trackEnded ({dispatch, rootState}, track) {
dispatch('trackListened', track)
let queueState = rootState.queue
if (queueState.currentIndex === queueState.tracks.length - 1) {
// we've reached last track of queue, trigger a reload
// from radio if any
dispatch('radios/populateQueue', null, {root: true})
}
dispatch('queue/next', null, {root: true})
dispatch('queue/next', null, {root: true})
},
trackErrored ({commit, dispatch}) {
......
......@@ -122,12 +122,25 @@ describe('store/player', () => {
testAction({
action: store.actions.trackEnded,
payload: {test: 'track'},
params: {rootState: {queue: {currentIndex:0, tracks: [1, 2]}}},
expectedActions: [
{ type: 'trackListened', payload: {test: 'track'} },
{ type: 'queue/next', payload: null, options: {root: true} }
]
}, done)
})
it('trackEnded calls populateQueue if last', (done) => {
testAction({
action: store.actions.trackEnded,
payload: {test: 'track'},
params: {rootState: {queue: {currentIndex:1, tracks: [1, 2]}}},
expectedActions: [
{ type: 'trackListened', payload: {test: 'track'} },
{ type: 'radios/populateQueue', payload: null, options: {root: true} },
{ type: 'queue/next', payload: null, options: {root: true} }
]
}, done)
})
it('trackErrored', (done) => {
testAction({
action: store.actions.trackErrored,
......
Supports Markdown
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