diff --git a/app/sites/[id]/page.tsx b/app/sites/[id]/page.tsx index d4ba1b9..0488ecb 100644 --- a/app/sites/[id]/page.tsx +++ b/app/sites/[id]/page.tsx @@ -100,7 +100,6 @@ export default function SiteDashboardPage() { const [isDatePickerOpen, setIsDatePickerOpen] = useState(false) const [isExportModalOpen, setIsExportModalOpen] = useState(false) const lastUpdatedAtRef = useRef(null) - const [, setTick] = useState(0) // Dimension filters state const searchParams = useSearchParams() @@ -374,12 +373,6 @@ export default function SiteDashboardPage() { if (overview) lastUpdatedAtRef.current = Date.now() }, [overview]) - // Tick every 1s so "Live · Xs ago" counts in real time - useEffect(() => { - const timer = setInterval(() => setTick((t) => t + 1), 1000) - return () => clearInterval(timer) - }, []) - // Save settings to localStorage const saveSettings = (type: string, newDateRange?: { start: string; end: string }) => { try { diff --git a/components/dashboard/Chart.tsx b/components/dashboard/Chart.tsx index 89faa38..d40cad7 100644 --- a/components/dashboard/Chart.tsx +++ b/components/dashboard/Chart.tsx @@ -161,6 +161,14 @@ export default function Chart({ const { resolvedTheme } = useTheme() const [showComparison, setShowComparison] = useState(false) + // Tick every 1s so "Live · Xs ago" counts in real time (scoped to Chart only) + const [, setTick] = useState(0) + useEffect(() => { + if (lastUpdatedAt == null) return + const timer = setInterval(() => setTick((t) => t + 1), 1000) + return () => clearInterval(timer) + }, [lastUpdatedAt]) + // ─── Annotation state ───────────────────────────────────────────── const [annotationForm, setAnnotationForm] = useState<{ visible: boolean; editingId?: string; date: string; time: string; text: string; category: string