From 54e9c27afb5923d3b5a8a664beaa9cc0f73a8be9 Mon Sep 17 00:00:00 2001 From: Roman Cervantes Date: Tue, 3 Sep 2019 21:09:31 -0700 Subject: [PATCH] Game board load bug fix --- src/pages/GameBoard.vue | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/src/pages/GameBoard.vue b/src/pages/GameBoard.vue index 01d3557d..2159096d 100755 --- a/src/pages/GameBoard.vue +++ b/src/pages/GameBoard.vue @@ -133,7 +133,7 @@ export default { mounted() { this.$store.commit('CLEAR_ACTIVE_LIST_INDEX'); - if (this.list && this.platform) { + if (this.platform) { this.load(); this.setPageTitle(); } else { @@ -215,7 +215,10 @@ export default { }, load() { - const flattenedList = this.list.map(({ games }) => games).flat(); + const flattenedList = this.list + ? this.list.map(({ games }) => games).flat() + : []; + const dedupedList = Array.from(new Set(flattenedList)); return dedupedList.length > this.queryLimit @@ -224,15 +227,17 @@ export default { }, loadGames(gameList) { - this.loading = true; + if (gameList && gameList.length > 0) { + this.loading = true; - this.$store.dispatch('LOAD_GAMES', gameList.toString()) - .then(() => { - this.loading = false; - }) - .catch(() => { - this.$bus.$emit('TOAST', { message: 'Error loading games', type: 'error' }); - }); + this.$store.dispatch('LOAD_GAMES', gameList.toString()) + .then(() => { + this.loading = false; + }) + .catch(() => { + this.$bus.$emit('TOAST', { message: 'Error loading games', type: 'error' }); + }); + } }, loadGamesInChunks(gameList) {