bandwidth savings configs

This commit is contained in:
legop3
2026-07-14 17:04:08 -04:00
parent 1c401ff90a
commit 0d6b4d68de
21 changed files with 424 additions and 39 deletions
+11 -1
View File
@@ -6,6 +6,7 @@ import { useSession } from '../context/SessionContext.jsx';
export function useSpectatorMode() {
const { session, setRole, subscribeAll, connected } = useSession();
const [ready, setReady] = useState(false);
const canUseSpectatorAccess = session?.bandwidthSavings?.canUseExternalSpectatorAccess !== false;
useEffect(() => {
let cancelled = false;
@@ -14,6 +15,15 @@ export function useSpectatorMode() {
setReady(false);
return;
}
if (!canUseSpectatorAccess) {
/*
The server will reject the role change too, but stopping here prevents
a blocked external spectator from retrying on every session sync while
the page is intentionally waiting for an admin grant or config change.
*/
setReady(false);
return;
}
try {
if (session?.role !== 'spectator') {
await setRole('spectator');
@@ -33,7 +43,7 @@ export function useSpectatorMode() {
return () => {
cancelled = true;
};
}, [connected, session?.mode, session?.role, setRole, subscribeAll]);
}, [canUseSpectatorAccess, connected, session?.mode, session?.role, setRole, subscribeAll]);
return ready;
}