mirror of
https://github.com/vkaelin/LeagueStats.git
synced 2026-03-25 12:57:28 +00:00
refactor: better way to store lastMatchId
This commit is contained in:
parent
565e2b32fa
commit
f6cd5e19a3
1 changed files with 5 additions and 9 deletions
|
|
@ -17,7 +17,6 @@ export const state = {
|
||||||
overview: {
|
overview: {
|
||||||
NB_LOAD_GAMES: 10,
|
NB_LOAD_GAMES: 10,
|
||||||
matches: [],
|
matches: [],
|
||||||
lastMatchId: null,
|
|
||||||
stats: {},
|
stats: {},
|
||||||
loaded: false,
|
loaded: false,
|
||||||
matchesLoading: false,
|
matchesLoading: false,
|
||||||
|
|
@ -57,9 +56,6 @@ export const mutations = {
|
||||||
},
|
},
|
||||||
KEEP_LAST_X_MATCHES(state, number) {
|
KEEP_LAST_X_MATCHES(state, number) {
|
||||||
state.overview.matches = state.overview.matches.slice(0, number)
|
state.overview.matches = state.overview.matches.slice(0, number)
|
||||||
if (state.overview.matches.length > 0) {
|
|
||||||
state.overview.lastMatchId = state.overview.matches[state.overview.matches.length - 1].matchId
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
LIVE_FOUND(state, { live }) {
|
LIVE_FOUND(state, { live }) {
|
||||||
state.live.match = live
|
state.live.match = live
|
||||||
|
|
@ -78,7 +74,6 @@ export const mutations = {
|
||||||
if (newMatches.length > 0) {
|
if (newMatches.length > 0) {
|
||||||
state.basic.recentActivity = stats.recentActivity
|
state.basic.recentActivity = stats.recentActivity
|
||||||
state.overview.matches = [...state.overview.matches, ...newMatches]
|
state.overview.matches = [...state.overview.matches, ...newMatches]
|
||||||
state.overview.lastMatchId = newMatches[newMatches.length - 1].matchId
|
|
||||||
state.overview.stats = stats
|
state.overview.stats = stats
|
||||||
state.champions.championsLoaded = false
|
state.champions.championsLoaded = false
|
||||||
state.records.recordsLoaded = false
|
state.records.recordsLoaded = false
|
||||||
|
|
@ -89,9 +84,6 @@ export const mutations = {
|
||||||
OVERVIEW_FOUND(state, infos) {
|
OVERVIEW_FOUND(state, infos) {
|
||||||
state.basic.recentActivity = infos.stats.recentActivity
|
state.basic.recentActivity = infos.stats.recentActivity
|
||||||
state.overview.matches = infos.matches
|
state.overview.matches = infos.matches
|
||||||
if (infos.matches.length > 0) {
|
|
||||||
state.overview.lastMatchId = infos.matches[infos.matches.length - 1].matchId
|
|
||||||
}
|
|
||||||
state.overview.stats = infos.stats
|
state.overview.stats = infos.stats
|
||||||
state.overview.loaded = true
|
state.overview.loaded = true
|
||||||
state.records.recordsLoaded = false
|
state.records.recordsLoaded = false
|
||||||
|
|
@ -197,12 +189,16 @@ export const actions = {
|
||||||
},
|
},
|
||||||
async moreMatches({ commit, rootState }) {
|
async moreMatches({ commit, rootState }) {
|
||||||
commit('MATCHES_LOADING')
|
commit('MATCHES_LOADING')
|
||||||
|
|
||||||
|
if (!state.overview.matches.length) return
|
||||||
|
const lastMatchId = state.overview.matches[state.overview.matches.length - 1].matchId
|
||||||
|
|
||||||
const resp = await axios(({
|
const resp = await axios(({
|
||||||
url: 'match',
|
url: 'match',
|
||||||
data: {
|
data: {
|
||||||
puuid: state.basic.account.puuid,
|
puuid: state.basic.account.puuid,
|
||||||
region: rootState.regionsList[rootState.settings.region],
|
region: rootState.regionsList[rootState.settings.region],
|
||||||
lastMatchId: state.overview.lastMatchId
|
lastMatchId
|
||||||
},
|
},
|
||||||
method: 'POST'
|
method: 'POST'
|
||||||
})).catch(() => { })
|
})).catch(() => { })
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue