mirror of
https://github.com/legop3/MultiRoombaRover.git
synced 2026-09-16 09:31:20 -04:00
bandwidth savings configs
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user