fix: reset loaded matches when the user switch tabs

This commit is contained in:
Valentin Kaelin 2020-08-12 14:27:45 +02:00
parent d50f562ee4
commit fc11c4909d
2 changed files with 12 additions and 1 deletions

View file

@ -50,6 +50,10 @@ export const mutations = {
state.champions.list = champions state.champions.list = champions
state.champions.championsLoaded = true state.champions.championsLoaded = true
}, },
KEEP_LAST_X_MATCHES(state, number) {
state.overview.matchIndex = number
state.overview.matches = state.overview.matches.slice(0, number)
},
LIVE_FOUND(state, { live }) { LIVE_FOUND(state, { live }) {
state.live.match = live state.live.match = live
state.live.liveLoaded = true state.live.liveLoaded = true
@ -190,6 +194,9 @@ export const actions = {
commit('RECORDS_FOUND', { records }) commit('RECORDS_FOUND', { records })
}, },
sliceOverviewMatches({ commit }, number) {
commit('KEEP_LAST_X_MATCHES', number)
},
updateSeason({ commit }, season) { updateSeason({ commit }, season) {
commit('UPDATE_SEASON', { season }) commit('UPDATE_SEASON', { season })
} }

View file

@ -99,8 +99,12 @@ export default {
if (!this.overviewLoaded && this.summonerFound) { if (!this.overviewLoaded && this.summonerFound) {
this.overviewRequest() this.overviewRequest()
} }
// Keep only the 10 last matches when summoner enters overview page
else if (this.overviewLoaded && this.summonerFound && this.overview.matches.length !== 10) {
this.sliceOverviewMatches(10)
}
}, },
...mapActions('summoner', ['moreMatches', 'overviewRequest']), ...mapActions('summoner', ['moreMatches', 'overviewRequest', 'sliceOverviewMatches']),
}, },
metaInfo() { metaInfo() {