fix: timer really fix this time, hopefully

This commit is contained in:
Valentin Kaelin 2020-01-19 16:48:28 +01:00
parent fc206ffe6c
commit 29605d4de9
3 changed files with 18 additions and 9 deletions

View file

@ -23,7 +23,7 @@
<router-link <router-link
v-if="!ally.bot" v-if="!ally.bot"
:to="{ name: 'summoner', params: { region: $route.params.region, name: ally.summonerName }}" :to="{ name: 'summoner', params: { region: $route.params.region, name: ally.summonerName }}"
:class="[compareSummonernames($route.params.name, ally.summonerName) ? 'text-white' : 'text-blue-200']" :class="[ally.summonerId === account.id ? 'text-white' : 'text-blue-200']"
class="relative ml-2 hover:text-white" class="relative ml-2 hover:text-white"
>{{ ally.summonerName }}</router-link> >{{ ally.summonerName }}</router-link>
</li> </li>

View file

@ -1,4 +1,3 @@
import { compareSummonernames } from '@/helpers/functions.js'
import { gameModes } from '@/data/data.js' import { gameModes } from '@/data/data.js'
import { mapState } from 'vuex' import { mapState } from 'vuex'
@ -26,7 +25,7 @@ export const liveGame = {
return gameModes[this.current.gameQueueConfigId] return gameModes[this.current.gameQueueConfigId]
}, },
gameStartTime() { gameStartTime() {
return (new Date() - new Date(this.current.gameStartTime)) / 1000 return this.current.gameStartTime
}, },
teamColor() { teamColor() {
return this.current.participants.find(p => p.summonerId === this.account.id).teamId return this.current.participants.find(p => p.summonerId === this.account.id).teamId
@ -38,14 +37,26 @@ export const liveGame = {
}, },
created() { created() {
this.gameLength = this.current ? this.gameStartTime : 0 this.updateGameLength()
setInterval(() => { setInterval(() => {
this.gameLength++ this.gameLength++
}, 1000) }, 1000)
}, },
watch: {
gameStartTime() {
this.updateGameLength()
}
},
methods: { methods: {
compareSummonernames, updateGameLength() {
if (this.gameStartTime === 0) {
return this.gameLength = 0
}
this.gameLength = (new Date() - new Date(this.gameStartTime)) / 1000
},
} }
} }

View file

@ -50,7 +50,6 @@ export default {
watch: { watch: {
summonerFound() { summonerFound() {
this.fetchData() this.fetchData()
this.gameLength = this.live ? this.gameStartTime : 0
} }
}, },
@ -59,10 +58,9 @@ export default {
}, },
methods: { methods: {
async fetchData() { fetchData() {
if (this.playing && !this.liveLoaded && this.summonerFound) { if (this.playing && !this.liveLoaded && this.summonerFound) {
await this.liveMatchRequest() this.liveMatchRequest()
this.gameLength = this.gameStartTime
} }
}, },
...mapActions('summoner', ['liveMatchRequest']), ...mapActions('summoner', ['liveMatchRequest']),