Merge branch '585-start-radio-immediatly' into 'develop'

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

Closes #585

See merge request funkwhale/funkwhale!454
merge-requests/466/head
Eliot Berriot 2018-10-21 14:56:56 +00:00
commit a6264d7deb
4 zmienionych plików z 13 dodań i 4 usunięć

Wyświetl plik

@ -0,0 +1 @@
Now start radios immediatly, skipping any existing tracks in queue (#585)

Wyświetl plik

@ -14,7 +14,7 @@
</div> </div>
</div> </div>
<div class="extra content"> <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> <radio-button class="right floated button" :type="type" :custom-radio-id="customRadioId"></radio-button>
<router-link <router-link
class="ui basic yellow button right floated" class="ui basic yellow button right floated"

Wyświetl plik

@ -135,6 +135,9 @@ export default {
} }
} }
}, },
last ({state, dispatch}) {
dispatch('currentIndex', state.tracks.length - 1)
},
currentIndex ({commit, state, rootState, dispatch}, index) { currentIndex ({commit, state, rootState, dispatch}, index) {
commit('ended', false) commit('ended', false)
commit('player/currentTime', 0, {root: true}) commit('player/currentTime', 0, {root: true})

Wyświetl plik

@ -48,7 +48,7 @@ export default {
logger.default.info('Successfully started radio ', type) logger.default.info('Successfully started radio ', type)
commit('current', {type, objectId, session: response.data.id, customRadioId}) commit('current', {type, objectId, session: response.data.id, customRadioId})
commit('running', true) commit('running', true)
dispatch('populateQueue') dispatch('populateQueue', true)
}, (response) => { }, (response) => {
logger.default.error('Error while starting radio', type) logger.default.error('Error while starting radio', type)
}) })
@ -57,7 +57,7 @@ export default {
commit('current', null) commit('current', null)
commit('running', false) commit('running', false)
}, },
populateQueue ({rootState, state, dispatch}) { populateQueue ({rootState, state, dispatch}, playNow) {
if (!state.running) { if (!state.running) {
return return
} }
@ -69,7 +69,12 @@ export default {
} }
return axios.post('radios/tracks/', params).then((response) => { return axios.post('radios/tracks/', params).then((response) => {
logger.default.info('Adding track to queue from radio') 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) => { }, (response) => {
logger.default.error('Error while adding track to queue from radio') logger.default.error('Error while adding track to queue from radio')
}) })