diff --git a/frontend/src/components/AutoLogout.vue b/frontend/src/components/AutoLogout.vue index 73f2dee10b10bc1429d294f0b59e9724d250be0c..83ab9f3e8995201f51f9fcc06d81c48f4a703022 100644 --- a/frontend/src/components/AutoLogout.vue +++ b/frontend/src/components/AutoLogout.vue @@ -31,13 +31,14 @@ <script lang="ts"> import Vue from 'vue' import Component, { mixins } from 'vue-class-component' +import { Watch } from 'vue-property-decorator' import { mapState } from 'vuex' import { Authentication } from '@/store/modules/authentication' import { actions } from '@/store/actions' +import { getters } from '@/store/getters' @Component({ - name: 'auto-logout', - computed: {...mapState(['lastAppInteraction'])} + name: 'auto-logout' }) export default class AutoLogout extends Vue { timer = 0 @@ -46,6 +47,7 @@ export default class AutoLogout extends Vue { get lastTokenRefreshTry () { return Authentication.state.lastTokenRefreshTry } get refreshingToken () { return Authentication.state.refreshingToken } get jwtTimeDelta () { return Authentication.state.jwtTimeDelta } + get lastAppInteraction () { return getters.state.lastAppInteraction } logout () { this.logoutDialog = false @@ -57,7 +59,8 @@ export default class AutoLogout extends Vue { this.logoutDialog = false } - lastAppInteraction () { + @Watch('lastAppInteraction') + onLastInteractionChange () { const timeSinceLastRefresh = Date.now() - this.lastTokenRefreshTry const timeDelta = this.jwtTimeDelta // refresh jwt if it's older than 20% of his maximum age @@ -67,10 +70,6 @@ export default class AutoLogout extends Vue { } } - watch () { - this.lastAppInteraction() - } - mounted () { this.timer = setInterval(() => { const timeDialogAppearsBeforeLogout = Math.min(600 * 1e3,