From 56b569f27e7871721797255b0fbd3f6810650f6e Mon Sep 17 00:00:00 2001 From: moinnet Date: Sun, 28 Nov 2021 21:13:12 +0100 Subject: [PATCH] Creation of a button to display 50 matchs --- client/src/store/modules/summoner.js | 32 ++++++++++++++++++++++++++++ client/src/views/Summoner.vue | 10 +++++++-- 2 files changed, 40 insertions(+), 2 deletions(-) diff --git a/client/src/store/modules/summoner.js b/client/src/store/modules/summoner.js index 931dc90..28878d2 100644 --- a/client/src/store/modules/summoner.js +++ b/client/src/store/modules/summoner.js @@ -75,6 +75,15 @@ export const mutations = { state.champions.championsLoaded = false state.records.recordsLoaded = false }, + MATCHES_FOUND50(state, { newMatches, stats }) { + state.basic.recentActivity = stats.recentActivity + state.overview.matchesLoading = false + state.overview.matches = [...state.overview.matches, ...newMatches] + state.overview.matchIndex += 50 + state.overview.stats = stats + state.champions.championsLoaded = false + state.records.recordsLoaded = false + }, OVERVIEW_FOUND(state, infos) { state.basic.recentActivity = infos.stats.recentActivity state.overview.matches = infos.matches @@ -200,6 +209,26 @@ export const actions = { const newMatches = createMatchData(resp.data.matches) commit('MATCHES_FOUND', { newMatches, stats: resp.data.stats }) }, + async more50Matches({ commit, getters, rootState }) { + commit('MATCHES_LOADING') + + const matchIds = getters.filteredMatchList + .slice(state.overview.matchIndex, state.overview.matchIndex + 50) + + const resp = await axios(({ + url: 'match', + data: { + puuid: state.basic.account.puuid, + region: rootState.regionsList[rootState.settings.region], + matchIds + }, + method: 'POST' + })).catch(() => { }) + console.log('---MATCHES INFOS---') + console.log(resp.data) + const newMatches = createMatchData(resp.data.matches) + commit('MATCHES_FOUND50', { newMatches, stats: resp.data.stats }) + }, async overviewRequest({ commit, rootState }) { const resp = await axios(({ url: 'summoner/overview', @@ -240,6 +269,9 @@ export const getters = { moreMatchesToFetch: (state, getters) => { return state.overview.matchIndex < getters.filteredMatchList.length }, + more50MatchesToFetch: (state, getters) => { + return state.overview.matchIndex < getters.filteredMatchList.length + }, overviewLoaded: state => state.overview.loaded, playing: state => state.live.playing, regionFilterApplied: state => !!state.basic.currentSeason, diff --git a/client/src/views/Summoner.vue b/client/src/views/Summoner.vue index 3698b09..09d3a16 100644 --- a/client/src/views/Summoner.vue +++ b/client/src/views/Summoner.vue @@ -33,6 +33,12 @@ :loading="matchesLoading" btn-class="block px-4 py-2 mx-auto mt-4 font-semibold bg-blue-800 rounded-md shadow-lg hover:bg-blue-1000" >More matches + More 50 matches
@@ -78,7 +84,7 @@ export default { current: state => state.summoner.live.match, overview: state => state.summoner.overview, }), - ...mapGetters('summoner', ['matchesLoading', 'moreMatchesToFetch', 'overviewLoaded', 'summonerFound']) + ...mapGetters('summoner', ['matchesLoading', 'moreMatchesToFetch', 'more50MatchesToFetch', 'overviewLoaded', 'summonerFound']) }, watch: { @@ -107,7 +113,7 @@ export default { } }, ...mapActions('cdragon', ['getRunes']), - ...mapActions('summoner', ['moreMatches', 'overviewRequest', 'sliceOverviewMatches']), + ...mapActions('summoner', ['moreMatches', 'more50Matches', 'overviewRequest', 'sliceOverviewMatches']), }, metaInfo() {