From 29605d4de92ffcc7b20da4b8cc1fc0927e3c9cc6 Mon Sep 17 00:00:00 2001 From: Valentin Kaelin Date: Sun, 19 Jan 2020 16:48:28 +0100 Subject: [PATCH] fix: timer really fix this time, hopefully --- client/src/components/Match/LiveMatch.vue | 2 +- client/src/mixins/liveGame.js | 19 +++++++++++++++---- client/src/views/SummonerLive.vue | 6 ++---- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/client/src/components/Match/LiveMatch.vue b/client/src/components/Match/LiveMatch.vue index 0e07287..fedcb4f 100644 --- a/client/src/components/Match/LiveMatch.vue +++ b/client/src/components/Match/LiveMatch.vue @@ -23,7 +23,7 @@ {{ ally.summonerName }} diff --git a/client/src/mixins/liveGame.js b/client/src/mixins/liveGame.js index 811283f..c46d3d4 100644 --- a/client/src/mixins/liveGame.js +++ b/client/src/mixins/liveGame.js @@ -1,4 +1,3 @@ -import { compareSummonernames } from '@/helpers/functions.js' import { gameModes } from '@/data/data.js' import { mapState } from 'vuex' @@ -26,7 +25,7 @@ export const liveGame = { return gameModes[this.current.gameQueueConfigId] }, gameStartTime() { - return (new Date() - new Date(this.current.gameStartTime)) / 1000 + return this.current.gameStartTime }, teamColor() { return this.current.participants.find(p => p.summonerId === this.account.id).teamId @@ -38,14 +37,26 @@ export const liveGame = { }, created() { - this.gameLength = this.current ? this.gameStartTime : 0 + this.updateGameLength() setInterval(() => { this.gameLength++ }, 1000) }, + watch: { + gameStartTime() { + this.updateGameLength() + } + }, + methods: { - compareSummonernames, + updateGameLength() { + if (this.gameStartTime === 0) { + return this.gameLength = 0 + } + + this.gameLength = (new Date() - new Date(this.gameStartTime)) / 1000 + }, } } diff --git a/client/src/views/SummonerLive.vue b/client/src/views/SummonerLive.vue index 30b732d..c3d4a09 100644 --- a/client/src/views/SummonerLive.vue +++ b/client/src/views/SummonerLive.vue @@ -50,7 +50,6 @@ export default { watch: { summonerFound() { this.fetchData() - this.gameLength = this.live ? this.gameStartTime : 0 } }, @@ -59,10 +58,9 @@ export default { }, methods: { - async fetchData() { + fetchData() { if (this.playing && !this.liveLoaded && this.summonerFound) { - await this.liveMatchRequest() - this.gameLength = this.gameStartTime + this.liveMatchRequest() } }, ...mapActions('summoner', ['liveMatchRequest']),