animate in browser context, fix clear interval

This commit is contained in:
Jonathan Baecker 2020-04-21 15:30:36 +02:00
parent 9e9407ac1c
commit 7ab8a20415

View File

@ -170,9 +170,7 @@ export default {
this.init()
},
beforeDestroy () {
if (this.interval) {
clearInterval(this.interval)
}
clearInterval(this.interval)
},
methods: {
async init () {
@ -195,6 +193,8 @@ export default {
}
},
async logout () {
clearInterval(this.interval)
try {
await this.$store.commit('auth/REMOVE_TOKEN')
await this.$store.commit('auth/UPDATE_IS_LOGIN', false)
@ -213,11 +213,13 @@ export default {
const response = await this.$axios.get('api/stats/?stats=all', { headers: { Authorization: 'Bearer ' + this.$store.state.auth.jwtToken }, progress: false })
this.stat = response.data
this.interval = setInterval(async () => {
await this.$store.dispatch('auth/inspectToken')
const response = await this.$axios.get('api/stats/?stats=all', { headers: { Authorization: 'Bearer ' + this.$store.state.auth.jwtToken }, progress: false })
this.stat = response.data
}, 2000)
if (process.browser) {
this.interval = setInterval(async () => {
await this.$store.dispatch('auth/inspectToken')
const response = await this.$axios.get('api/stats/?stats=all', { headers: { Authorization: 'Bearer ' + this.$store.state.auth.jwtToken }, progress: false })
this.stat = response.data
}, 2000)
}
}
}
}