You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
698 B

  1. <script lang="ts">
  2. import { onMount } from "svelte";
  3. import goalStore, { fpGoalStore } from "../stores/goal";
  4. import logStore from "../stores/logs";
  5. import projectStore, { fpProjectStore } from "../stores/project";
  6. let lastFocus = new Date();
  7. function handleFocus() {
  8. if (Date.now() - lastFocus.getTime() < 60000) {
  9. return;
  10. }
  11. lastFocus = new Date();
  12. goalStore.markStale();
  13. fpGoalStore.markStale();
  14. projectStore.markStale();
  15. fpProjectStore.markStale();
  16. logStore.markStale();
  17. }
  18. onMount(() => {
  19. window.addEventListener("focus", handleFocus);
  20. return () => {
  21. window.removeEventListener("focus", handleFocus);
  22. }
  23. })
  24. </script>