From d9af6b795049c7dc755ca646804fdc04510e9724 Mon Sep 17 00:00:00 2001 From: Xevion Date: Sat, 12 Sep 2020 13:33:33 -0500 Subject: [PATCH] fix SeasonList to use Vuex properly (working Skeleton loading), fix $store vs $state misunderstandings --- client/src/components/SeasonList.vue | 79 ++++++++++++---------------- client/src/store.js | 12 +++-- 2 files changed, 42 insertions(+), 49 deletions(-) diff --git a/client/src/components/SeasonList.vue b/client/src/components/SeasonList.vue index ebe7f8e..3d3646d 100644 --- a/client/src/components/SeasonList.vue +++ b/client/src/components/SeasonList.vue @@ -23,33 +23,33 @@ > - diff --git a/client/src/store.js b/client/src/store.js index 6c04efd..1d7802d 100644 --- a/client/src/store.js +++ b/client/src/store.js @@ -18,7 +18,7 @@ export default new Vuex.Store({ state: { seasonCount: 9, episodeCount: episodeCount, - quoteData: baseData + quoteData: baseData, }, mutations: { [types.SET_EPISODE](state, payload) { @@ -44,18 +44,22 @@ export default new Vuex.Store({ getters: { // Check whether a episode has been fetched yet isFetched(season, episode) { - return this.state.quoteData[season - 1].episodes[episode] !== null; + return this.$store.state.quoteData[season - 1].episodes[episode] !== null; }, // Get the number of episodes present for a given season getEpisodeCount(season) { - return this.state.episodeCount[season - 1]; + return this.$store.state.episodeCount[season - 1]; }, // return Episode data if present getEpisode(season, episode) { if (this.getters.isFetched(season, episode)) - return this.state.quoteData[season] + return this.$store.state.quoteData[season] else return null + }, + // return true if a specific episode is valid + isValidEpisode(season, episode = 1) { + return season >= 1 && season <= 9 && episode >= 1 && episode <= this.$store.getters.getEpisodeCount(season) } } });