Fixed #384: unfiltered results in favorites API

This commit is contained in:
Eliot Berriot 2018-07-22 11:56:25 +02:00
commit 25755ad39b
No known key found for this signature in database
GPG key ID: DD6965E2476E5C27
6 changed files with 26 additions and 5 deletions

View file

@ -11,7 +11,7 @@
<translate
translate-plural="%{ count } favorites"
:translate-n="$store.state.favorites.count"
:translate-params="{count: $store.state.favorites.count}">
:translate-params="{count: results.count}">
1 favorite
</translate>
</h2>

View file

@ -53,10 +53,13 @@ export default {
toggle ({getters, dispatch}, id) {
dispatch('set', {id, value: !getters['isFavorite'](id)})
},
fetch ({dispatch, state, commit}, url) {
fetch ({dispatch, state, commit, rootState}, url) {
// will fetch favorites by batches from API to have them locally
let params = {
user: rootState.auth.profile.id
}
url = url || 'favorites/tracks/'
return axios.get(url).then((response) => {
return axios.get(url, {params: params}).then((response) => {
logger.default.info('Fetched a batch of ' + response.data.results.length + ' favorites')
response.data.results.forEach(result => {
commit('track', {id: result.track, value: true})