diff --git a/src/components/BasePuzzleListPage.vue b/src/components/BasePuzzleListPage.vue index 1fb1a62..d0f5c45 100644 --- a/src/components/BasePuzzleListPage.vue +++ b/src/components/BasePuzzleListPage.vue @@ -75,6 +75,7 @@ import PuzzleCard from '../components/PuzzleCard.vue' import { Action, Achievement, PuzzleItem, PuzzleList } from '../store'; import ChatManager from '../ChatManager'; +const PAGE_SIZE = 9; export default Vue.extend({ props: { @@ -91,10 +92,11 @@ export default Vue.extend({ data() { return { availableFilters: [] as {value: string; text: string}[], - numberOfPuzzles: 9, + numberOfPuzzles: PAGE_SIZE, playablePuzzleIndex: 0, chat: null, logoSourcePng: require('../assets/logo_eterna.svg'), + firstLoad: true }; }, async mounted() { @@ -211,11 +213,12 @@ export default Vue.extend({ if (!query.progression) queryParams.append('size', this.numberOfPuzzles.toString(10)); - await this.$store.dispatch(Action.GET_PUZZLES, queryParams.toString()); + await this.$store.dispatch(Action.GET_PUZZLES, {queryString: queryParams.toString(), firstLoad: this.firstLoad}); + this.firstLoad = false; } }, async fetchMorePuzzles() { - this.numberOfPuzzles += 9; + this.numberOfPuzzles += PAGE_SIZE; await this.fetchNewPuzzles(); }, async logout() { diff --git a/src/store/index.ts b/src/store/index.ts index e408496..5e2f8f1 100644 --- a/src/store/index.ts +++ b/src/store/index.ts @@ -384,15 +384,15 @@ export default function createStore(http: AxiosInstance) { commit('popIsLoading'); } }, - async [Action.GET_LABS]({ commit }, queryString: string){ - // commit('pushIsLoading'); + async [Action.GET_LABS]({ commit }, { queryString, firstLoad }: { queryString: string; firstLoad?: boolean}){ + if (firstLoad) commit('pushIsLoading'); try{ const { data } = (await http.get(`/get/?${queryString}`)).data; commit('setLabTotal', parseInt(data.num_labs)); commit('setLabs', data.labs); } finally{ - // commit('popIsLoading'); + if (firstLoad) commit('popIsLoading'); } }, async [Action.GET_LAB]({ commit }, { id }: { id: string}){ @@ -431,14 +431,14 @@ export default function createStore(http: AxiosInstance) { commit('popIsLoading'); } }, - async [Action.GET_PUZZLES]({ commit }, queryString: string){ - // commit('pushIsLoading'); + async [Action.GET_PUZZLES]({ commit }, { queryString, firstLoad }: { queryString: string; firstLoad?: boolean}){ + if (firstLoad) commit('pushIsLoading'); try{ const { data } = (await http.get(`/get/?${queryString}`)).data; commit('setPuzzles', data); } finally{ - // commit('popIsLoading'); + if (firstLoad) commit('popIsLoading'); } }, async [Action.GET_PUZZLE]({ commit }, { id }: { id: string}){ diff --git a/src/views/LabExplore.vue b/src/views/LabExplore.vue index 74c7dbe..625c31b 100644 --- a/src/views/LabExplore.vue +++ b/src/views/LabExplore.vue @@ -58,6 +58,8 @@ import { Action, Achievement, LabData } from '../store'; import ChatManager from '../ChatManager'; import DefaultLabHero from '../assets/slides/hero-lab-default.png'; +const PAGE_SIZE = 9; + export default Vue.extend({ data() { return { @@ -65,11 +67,12 @@ export default Vue.extend({ { value: 'active', text: 'Active' }, { value: 'inactive', text: 'Inactive' } ], - numberOfLabs: 9, + numberOfLabs: PAGE_SIZE, playablePuzzleIndex: 0, chat: null, logoSourcePng: require('../assets/logo_eterna.svg'), - defaultLabImage: DefaultLabHero + defaultLabImage: DefaultLabHero, + firstLoad: true }; }, async mounted() { @@ -114,10 +117,11 @@ export default Vue.extend({ let labFilter = requestString; if (filters.includes("active") && !filters.includes("inactive")) {labFilter = `${requestString}&filters=active`} if (filters.includes("inactive") && !filters.includes("active")) {labFilter = `${requestString}&filters=inactive`} - await this.$store.dispatch(Action.GET_LABS, labFilter); + await this.$store.dispatch(Action.GET_LABS, {queryString: labFilter, firstLoad: this.firstLoad}); + this.firstLoad = false; }, async fetchMoreLabs() { - this.numberOfLabs += 9; + this.numberOfLabs += PAGE_SIZE; await this.fetchNewLabs(); }, async logout() {