fix: filter champions by queue: reset queue when tab is changed

This commit is contained in:
Valentin Kaelin 2020-01-08 19:04:58 +01:00
parent 22ff28d6a0
commit 93f57e8c7d
2 changed files with 16 additions and 1 deletions

View file

@ -18,6 +18,8 @@
</template> </template>
<script> <script>
import { mapActions } from 'vuex'
export default { export default {
props: { props: {
choices: { choices: {
@ -36,10 +38,17 @@ export default {
this.queue = -1 this.queue = -1
}, },
destroyed() {
// Reload all champions stats for next user visit of the champions tab
if (this.queue !== -1)
this.championsNotLoaded()
},
methods: { methods: {
filterQueue() { filterQueue() {
this.$emit('filter-queue', this.queue) this.$emit('filter-queue', this.queue)
} },
...mapActions('summoner', ['championsNotLoaded']),
} }
} }
</script> </script>

View file

@ -31,6 +31,9 @@ export const mutations = {
state.champions.championsLoaded = false state.champions.championsLoaded = false
state.overview.loaded = false state.overview.loaded = false
}, },
CHAMPIONS_NOT_FOUND(state) {
state.champions.championsLoaded = false
},
CHAMPIONS_FOUND(state, { champions }) { CHAMPIONS_FOUND(state, { champions }) {
state.champions.list = champions state.champions.list = champions
state.champions.championsLoaded = true state.champions.championsLoaded = true
@ -91,6 +94,9 @@ export const actions = {
console.log(error) console.log(error)
} }
}, },
championsNotLoaded({ commit }) {
commit('CHAMPIONS_NOT_FOUND')
},
async championsRequest({ commit }, queue = null) { async championsRequest({ commit }, queue = null) {
const resp = await axios(({ url: 'summoner-champions', data: { puuid: state.basic.account.puuid, queue: queue }, method: 'POST' })).catch(() => { }) const resp = await axios(({ url: 'summoner-champions', data: { puuid: state.basic.account.puuid, queue: queue }, method: 'POST' })).catch(() => { })
console.log('---CHAMPIONS---') console.log('---CHAMPIONS---')