From d740ed730964fe66a24f70166d9aeabdbeb9f64e Mon Sep 17 00:00:00 2001 From: Valentin Kaelin Date: Wed, 15 Jan 2020 21:55:22 +0100 Subject: [PATCH] feat: add reload button on live game tab --- client/src/mixins/liveGame.js | 5 ++++- client/src/store/modules/summoner.js | 8 +++++++- client/src/views/SummonerLive.vue | 17 ++++++++++------- .../app/Controllers/Http/SummonerController.js | 2 +- 4 files changed, 22 insertions(+), 10 deletions(-) diff --git a/client/src/mixins/liveGame.js b/client/src/mixins/liveGame.js index 6b8b3a6..96dca6d 100644 --- a/client/src/mixins/liveGame.js +++ b/client/src/mixins/liveGame.js @@ -19,6 +19,9 @@ export const liveGame = { gamemode() { return gameModes[this.current.gameQueueConfigId] }, + gameStartTime() { + return (new Date() - new Date(this.current.gameStartTime)) / 1000 + }, teamColor() { return this.current.participants.find(p => p.summonerId === this.account.id).teamId }, @@ -29,7 +32,7 @@ export const liveGame = { }, created() { - this.gameLength = this.current ? this.current.gameLength : 0 + this.gameLength = this.current ? this.gameStartTime : 0 setInterval(() => { this.gameLength++ diff --git a/client/src/store/modules/summoner.js b/client/src/store/modules/summoner.js index 2983221..bd82306 100644 --- a/client/src/store/modules/summoner.js +++ b/client/src/store/modules/summoner.js @@ -52,6 +52,9 @@ export const mutations = { state.live.match = live state.live.liveLoaded = true }, + LIVE_NOT_FOUND(state) { + state.live.liveLoaded = false + }, MATCHES_LOADING(state) { state.overview.matchesLoading = true }, @@ -124,11 +127,14 @@ export const actions = { commit('CHAMPIONS_FOUND', { champions: resp.data }) }, async liveMatchRequest({ commit, rootState }) { + commit('LIVE_NOT_FOUND') const resp = await axios(({ url: 'summoner-live', data: { account: state.basic.account, region: rootState.currentRegion }, method: 'POST' })).catch(() => { }) console.log('---LIVE---') console.log(resp.data) - commit('LIVE_FOUND', { live: resp.data }) + if (resp.data) { + commit('LIVE_FOUND', { live: resp.data }) + } }, async moreMatches({ commit }) { commit('MATCHES_LOADING') diff --git a/client/src/views/SummonerLive.vue b/client/src/views/SummonerLive.vue index 633eeea..4a2a928 100644 --- a/client/src/views/SummonerLive.vue +++ b/client/src/views/SummonerLive.vue @@ -1,14 +1,16 @@