feat(streamer): react views ported from prototype with sse hooks

This commit is contained in:
devilreef 2026-04-30 15:26:57 +06:00
parent 870a41a2f7
commit e0d93b03ae
Signed by: devilreef
SSH key fingerprint: SHA256:UZisRr4iuXx+IhkbZnR655L2RWAT6o2rgbGv5F/6m3Y
9 changed files with 672 additions and 0 deletions

View file

@ -0,0 +1,10 @@
import { useEffect, useState } from "react";
export function useElapsed(startedAt: number, duration: number): number {
const [now, setNow] = useState(() => Date.now() / 1000);
useEffect(() => {
const t = setInterval(() => setNow(Date.now() / 1000), 200);
return () => clearInterval(t);
}, []);
return Math.min(duration, Math.max(0, now - startedAt));
}