fix(more-matches): no longer display the load button unnecessarily

When the season filter is selected: check if there is more matches to load or not.
This commit is contained in:
Valentin Kaelin 2020-11-14 18:40:26 +01:00
parent 44f10b6c35
commit 67ff3380a0

View file

@ -178,8 +178,7 @@ export const actions = {
async moreMatches({ commit, getters, rootState }) { async moreMatches({ commit, getters, rootState }) {
commit('MATCHES_LOADING') commit('MATCHES_LOADING')
const gameIds = state.basic.matchList const gameIds = getters.filteredMatchList
.filter(match => !getters.regionFilterApplied || match.seasonMatch === state.basic.currentSeason)
.slice(state.overview.matchIndex, state.overview.matchIndex + 10) .slice(state.overview.matchIndex, state.overview.matchIndex + 10)
.map(({ gameId }) => gameId) .map(({ gameId }) => gameId)
@ -230,8 +229,14 @@ export const actions = {
} }
export const getters = { export const getters = {
filteredMatchList: (state, getters) => {
return state.basic.matchList
.filter(match => !getters.regionFilterApplied || match.seasonMatch === state.basic.currentSeason)
},
matchesLoading: state => state.overview.matchesLoading, matchesLoading: state => state.overview.matchesLoading,
moreMatchesToFetch: state => state.overview.matchIndex < state.basic.matchList.length, moreMatchesToFetch: (state, getters) => {
return state.overview.matchIndex < getters.filteredMatchList.length
},
overviewLoaded: state => state.overview.loaded, overviewLoaded: state => state.overview.loaded,
playing: state => state.live.playing, playing: state => state.live.playing,
regionFilterApplied: state => !!state.basic.currentSeason, regionFilterApplied: state => !!state.basic.currentSeason,