import type { Signal } from "@preact/signals"; import { Button } from "../components/Button.tsx"; interface SharedProps { count: Signal; localCount: Signal; globalCount: Signal; hasClicked: Signal; } export default function Counter(props: SharedProps) { const onClick = () => { props.count.value += 1; props.localCount.value += 1; props.hasClicked.value = true; // set a timer to update the global count, resetting // whenever a user activity is detected let timer: number; timer = setTimeout(async () => { // TODO: add the upload code here }, 5000); window.onclick = () => { clearTimeout(timer); timer = setTimeout(async () => { // Upload code goes here }, 5000); } } return (

{props.count}

Times clicked

Everyone has clicked the button {props.globalCount} times!

); }