@@ -24,6 +24,7 @@
|
||||
import GoalForm from "./forms/GoalForm.svelte";
|
||||
import LoginForm from "./forms/LoginForm.svelte";
|
||||
import authStore from "./stores/auth";
|
||||
import FocusHandler from "./components/FocusHandler.svelte";
|
||||
|
||||
onMount(() => {
|
||||
authStore.check()
|
||||
@@ -32,6 +33,7 @@
|
||||
|
||||
{#if $authStore.checked}
|
||||
{#if $authStore.loggedIn}
|
||||
<FocusHandler />
|
||||
<Router>
|
||||
<Menu />
|
||||
<main>
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
<script lang="ts">
|
||||
import { onMount } from "svelte";
|
||||
import goalStore, { fpGoalStore } from "../stores/goal";
|
||||
import logStore from "../stores/logs";
|
||||
import projectStore, { fpProjectStore } from "../stores/project";
|
||||
|
||||
let lastFocus = new Date();
|
||||
|
||||
function handleFocus() {
|
||||
if (Date.now() - lastFocus.getTime() < 60000) {
|
||||
return;
|
||||
}
|
||||
|
||||
lastFocus = new Date();
|
||||
|
||||
goalStore.markStale();
|
||||
fpGoalStore.markStale();
|
||||
projectStore.markStale();
|
||||
fpProjectStore.markStale();
|
||||
logStore.markStale();
|
||||
}
|
||||
|
||||
onMount(() => {
|
||||
window.addEventListener("focus", handleFocus);
|
||||
|
||||
return () => {
|
||||
window.removeEventListener("focus", handleFocus);
|
||||
}
|
||||
})
|
||||
</script>
|
||||
Reference in New Issue
Block a user