mirror of
https://github.com/directus/directus.git
synced 2026-04-25 03:00:53 -04:00
Debounce app idle tracker autorefresh token (#8337)
* Debounce app autorefresh token process * Bump debounce time a notch Co-authored-by: rijkvanzanten <rijkvanzanten@me.com>
This commit is contained in:
@@ -2,6 +2,7 @@ import api from '@/api';
|
||||
import { dehydrate, hydrate } from '@/hydrate';
|
||||
import { router } from '@/router';
|
||||
import { useAppStore } from '@/stores';
|
||||
import { debounce } from 'lodash';
|
||||
import { RouteLocationRaw } from 'vue-router';
|
||||
import { idleTracker } from './idle';
|
||||
|
||||
@@ -52,19 +53,25 @@ idleTracker.on('hide', () => {
|
||||
});
|
||||
|
||||
// Restart the autorefresh process when the app is used (again)
|
||||
idleTracker.on('active', () => {
|
||||
if (idle === true) {
|
||||
refresh();
|
||||
idle = false;
|
||||
}
|
||||
});
|
||||
idleTracker.on(
|
||||
'active',
|
||||
debounce(() => {
|
||||
if (idle === true) {
|
||||
refresh();
|
||||
idle = false;
|
||||
}
|
||||
}, 1000)
|
||||
);
|
||||
|
||||
idleTracker.on('show', () => {
|
||||
if (idle === true) {
|
||||
refresh();
|
||||
idle = false;
|
||||
}
|
||||
});
|
||||
idleTracker.on(
|
||||
'show',
|
||||
debounce(() => {
|
||||
if (idle === true) {
|
||||
refresh();
|
||||
idle = false;
|
||||
}
|
||||
}, 1000)
|
||||
);
|
||||
|
||||
export async function refresh({ navigate }: LogoutOptions = { navigate: true }): Promise<string | undefined> {
|
||||
const appStore = useAppStore();
|
||||
|
||||
Reference in New Issue
Block a user