From a1b5dca17ff6423b5df92a28ae70ceef40991867 Mon Sep 17 00:00:00 2001 From: rijkvanzanten Date: Fri, 7 Aug 2020 13:59:36 -0400 Subject: [PATCH] Reset page track if you navigate multiple times within 2.5s --- app/src/router.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/src/router.ts b/app/src/router.ts index 73200620a2..39778616c8 100644 --- a/app/src/router.ts +++ b/app/src/router.ts @@ -117,12 +117,20 @@ export const onBeforeEach: NavigationGuard = async (to, from, next) => { return next(); }; +let trackTimeout: number | null= null; + export const onAfterEach = (to: Route) => { const userStore = useUserStore(); if (to.meta.public !== true) { // The timeout gives the page some breathing room to load. No need to clog up the thread with // this call while more important things are loading + + if (trackTimeout) { + clearTimeout(trackTimeout); + trackTimeout = null; + } + setTimeout(() => { userStore.trackPage(to.fullPath); }, 2500);