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