diff --git a/client/src/store/modules/summoner.js b/client/src/store/modules/summoner.js index ba7a805..c30233b 100644 --- a/client/src/store/modules/summoner.js +++ b/client/src/store/modules/summoner.js @@ -50,6 +50,10 @@ export const mutations = { state.champions.list = champions 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 }) { state.live.match = live state.live.liveLoaded = true @@ -190,6 +194,9 @@ export const actions = { commit('RECORDS_FOUND', { records }) }, + sliceOverviewMatches({ commit }, number) { + commit('KEEP_LAST_X_MATCHES', number) + }, updateSeason({ commit }, season) { commit('UPDATE_SEASON', { season }) } diff --git a/client/src/views/Summoner.vue b/client/src/views/Summoner.vue index a16916f..3b175b1 100644 --- a/client/src/views/Summoner.vue +++ b/client/src/views/Summoner.vue @@ -99,8 +99,12 @@ export default { if (!this.overviewLoaded && this.summonerFound) { 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() {