Verified Commit 5c8aff20 authored by Agate's avatar Agate 💬

Fix #585: Now start radios immediatly, skipping any existing tracks in queue

parent 7a5a7208
Pipeline #2277 passed with stages
in 4 minutes and 54 seconds
Now start radios immediatly, skipping any existing tracks in queue (#585)
......@@ -14,7 +14,7 @@
</div>
</div>
<div class="extra content">
<user-link :user="radio.user" class="left floated" />
<user-link v-if="radio.user" :user="radio.user" class="left floated" />
<radio-button class="right floated button" :type="type" :custom-radio-id="customRadioId"></radio-button>
<router-link
class="ui basic yellow button right floated"
......
......@@ -135,6 +135,9 @@ export default {
}
}
},
last ({state, dispatch}) {
dispatch('currentIndex', state.tracks.length - 1)
},
currentIndex ({commit, state, rootState, dispatch}, index) {
commit('ended', false)
commit('player/currentTime', 0, {root: true})
......
......@@ -48,7 +48,7 @@ export default {
logger.default.info('Successfully started radio ', type)
commit('current', {type, objectId, session: response.data.id, customRadioId})
commit('running', true)
dispatch('populateQueue')
dispatch('populateQueue', true)
}, (response) => {
logger.default.error('Error while starting radio', type)
})
......@@ -57,7 +57,7 @@ export default {
commit('current', null)
commit('running', false)
},
populateQueue ({rootState, state, dispatch}) {
populateQueue ({rootState, state, dispatch}, playNow) {
if (!state.running) {
return
}
......@@ -69,7 +69,12 @@ export default {
}
return axios.post('radios/tracks/', params).then((response) => {
logger.default.info('Adding track to queue from radio')
dispatch('queue/append', {track: response.data.track}, {root: true})
let append = dispatch('queue/append', {track: response.data.track}, {root: true})
if (playNow) {
append.then(() => {
dispatch('queue/last', null, {root: true})
})
}
}, (response) => {
logger.default.error('Error while adding track to queue from radio')
})
......
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