From cecd6115a065bcc77da870e10b64f6cbbafe2228 Mon Sep 17 00:00:00 2001 From: Valentin Kaelin Date: Mon, 23 Dec 2019 22:35:46 +0100 Subject: [PATCH] refactor: use 1 array instead of 2 for championsList --- .../Summoner/Champions/ChampionsTable.vue | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/client/src/components/Summoner/Champions/ChampionsTable.vue b/client/src/components/Summoner/Champions/ChampionsTable.vue index a606bae..e292ba1 100644 --- a/client/src/components/Summoner/Champions/ChampionsTable.vue +++ b/client/src/components/Summoner/Champions/ChampionsTable.vue @@ -87,7 +87,7 @@ class="px-2 py-3 text-white text-sm" >{{ champion.gameLength|secToTime }} {{ champion.lastPlayed }} @@ -167,13 +167,17 @@ export default { } ], championsFull: [], - championsToDisplay: [], sortProps: 'index', order: -1 } }, computed: { + championsToDisplay() { + return this.championsFull.filter(c => { + return c.champion.name.toLowerCase().includes(this.search.toLowerCase()) + }) + }, totalGames() { return this.champions.reduce((agg, champ) => agg + champ.count, 0) } @@ -182,15 +186,10 @@ export default { watch: { champions() { this.updateChampionsList() - }, - search() { - this.championsToDisplay = this.championsFull.filter(c => { - return c.champion.name.toLowerCase().includes(this.search.toLowerCase()) - }) } }, - mounted() { + created() { this.updateChampionsList() }, @@ -244,8 +243,6 @@ export default { show: true } }) - - this.championsToDisplay = this.championsFull } }