From c2d5d54592e5accabc2a91c3e164b619907a4b64 Mon Sep 17 00:00:00 2001 From: Nik Afiq Date: Tue, 11 Nov 2025 18:06:45 +0900 Subject: [PATCH] Added time sync --- frontend/src/App.tsx | 6 ++ frontend/src/components/TimeSyncNotice.tsx | 62 ++++++++++++++ frontend/src/components/Timer.tsx | 96 ++++++++++----------- frontend/src/hooks/useServerClock.ts | 52 ++++++++++++ frontend/src/hooks/useTimeSkew.ts | 87 +++++++++++++++++++ frontend/src/index.css | 97 +++++++++++++++++++++- 6 files changed, 346 insertions(+), 54 deletions(-) create mode 100644 frontend/src/components/TimeSyncNotice.tsx create mode 100644 frontend/src/hooks/useServerClock.ts create mode 100644 frontend/src/hooks/useTimeSkew.ts diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index e243be1..2b600b8 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -2,8 +2,11 @@ import React from "react"; import { Link, NavLink, Route, Routes, useLocation } from "react-router-dom"; import Timer from "./components/Timer"; import ShowsPage from "./pages/ShowsPage"; +import TimeSyncNotice from "./components/TimeSyncNotice"; import "./index.css"; +const TIME_SYNC_OFF_THRESHOLD = 1000; + export default function App() { const [open, setOpen] = React.useState(false); const loc = useLocation(); @@ -22,6 +25,7 @@ export default function App() {
{/* Top-left header (outside the card) */}
+
+ {/* Time sync banner (checks every 5 min; shows if |skew| > 500ms) */} + {/* Sidebar (full-height) */}