Reset page track if you navigate multiple times within 2.5s

This commit is contained in:
rijkvanzanten
2020-08-07 13:59:36 -04:00
parent 581d8e34da
commit a1b5dca17f

View File

@@ -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);