mirror of
https://github.com/legop3/MultiRoombaRover.git
synced 2026-09-16 01:21:20 -04:00
just show em all, all the time
This commit is contained in:
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -11,7 +11,7 @@
|
|||||||
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
|
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
|
||||||
<meta name="apple-mobile-web-app-title" content="Multi Roomba Rover" />
|
<meta name="apple-mobile-web-app-title" content="Multi Roomba Rover" />
|
||||||
<title>Multi Roomba Rover</title>
|
<title>Multi Roomba Rover</title>
|
||||||
<script type="module" crossorigin src="/assets/index-MsCzfGxI.js"></script>
|
<script type="module" crossorigin src="/assets/index-DJv47phz.js"></script>
|
||||||
<link rel="stylesheet" crossorigin href="/assets/index-C97A4E-6.css">
|
<link rel="stylesheet" crossorigin href="/assets/index-C97A4E-6.css">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ import AlertFeed from '../components/AlertFeed.jsx';
|
|||||||
import useDefaultNickname from '../hooks/useDefaultNickname.js';
|
import useDefaultNickname from '../hooks/useDefaultNickname.js';
|
||||||
|
|
||||||
const ROTATE_MS = 20000;
|
const ROTATE_MS = 20000;
|
||||||
const PREWARM_MS = 5000;
|
|
||||||
const HARD_REFRESH_MS = 3 * 60 * 60 * 1000;
|
const HARD_REFRESH_MS = 3 * 60 * 60 * 1000;
|
||||||
|
|
||||||
function formatDriverLabel({ roverId, session }) {
|
function formatDriverLabel({ roverId, session }) {
|
||||||
@@ -220,10 +219,6 @@ function MiniSummaryContent() {
|
|||||||
const frames = useTelemetryFrames();
|
const frames = useTelemetryFrames();
|
||||||
const roster = session?.roster ?? [];
|
const roster = session?.roster ?? [];
|
||||||
const [index, setIndex] = useState(0);
|
const [index, setIndex] = useState(0);
|
||||||
const [primaryRoverId, setPrimaryRoverId] = useState(null);
|
|
||||||
const [secondaryRoverId, setSecondaryRoverId] = useState(null);
|
|
||||||
const [visibleSlot, setVisibleSlot] = useState('primary');
|
|
||||||
const prewarmTimer = useRef(null);
|
|
||||||
const activeDrivers = session?.activeDrivers || {};
|
const activeDrivers = session?.activeDrivers || {};
|
||||||
const driverRoster = useMemo(
|
const driverRoster = useMemo(
|
||||||
() => roster.filter((rover) => activeDrivers[rover.id]),
|
() => roster.filter((rover) => activeDrivers[rover.id]),
|
||||||
@@ -283,12 +278,6 @@ function MiniSummaryContent() {
|
|||||||
setIndex(0);
|
setIndex(0);
|
||||||
}, [rotationKey]);
|
}, [rotationKey]);
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
setPrimaryRoverId(rotationPool[0]?.rover?.id || null);
|
|
||||||
setSecondaryRoverId(null);
|
|
||||||
setVisibleSlot('primary');
|
|
||||||
}, [rotationKey, rotationPool]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!rotationPool.length) return undefined;
|
if (!rotationPool.length) return undefined;
|
||||||
const timer = setInterval(() => {
|
const timer = setInterval(() => {
|
||||||
@@ -297,63 +286,13 @@ function MiniSummaryContent() {
|
|||||||
return () => clearInterval(timer);
|
return () => clearInterval(timer);
|
||||||
}, [rotationPool.length, rotationKey]);
|
}, [rotationPool.length, rotationKey]);
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
clearTimeout(prewarmTimer.current);
|
|
||||||
if (!canSpectateVideo || rotationPool.length < 2) {
|
|
||||||
setSecondaryRoverId(null);
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
const nextIndex = (index + 1) % rotationPool.length;
|
|
||||||
const delay = Math.max(0, ROTATE_MS - PREWARM_MS);
|
|
||||||
prewarmTimer.current = setTimeout(() => {
|
|
||||||
const nextEntry = rotationPool[nextIndex];
|
|
||||||
const nextId = nextEntry?.rover?.id || null;
|
|
||||||
if (!nextId) {
|
|
||||||
setSecondaryRoverId(null);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (visibleSlot === 'primary') {
|
|
||||||
setSecondaryRoverId(nextId);
|
|
||||||
} else {
|
|
||||||
setPrimaryRoverId(nextId);
|
|
||||||
}
|
|
||||||
}, delay);
|
|
||||||
return () => clearTimeout(prewarmTimer.current);
|
|
||||||
}, [index, rotationPool, canSpectateVideo, visibleSlot]);
|
|
||||||
|
|
||||||
const activeEntry = rotationPool.length ? rotationPool[index % rotationPool.length] : null;
|
const activeEntry = rotationPool.length ? rotationPool[index % rotationPool.length] : null;
|
||||||
const activeRover = activeEntry?.type === 'rover' ? activeEntry.rover : null;
|
const activeRover = activeEntry?.type === 'rover' ? activeEntry.rover : null;
|
||||||
const activeRoverId = activeRover?.id || null;
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (!activeRoverId) return;
|
|
||||||
if (activeRoverId === primaryRoverId) {
|
|
||||||
setVisibleSlot('primary');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (activeRoverId === secondaryRoverId) {
|
|
||||||
setVisibleSlot('secondary');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
setPrimaryRoverId(activeRoverId);
|
|
||||||
setVisibleSlot('primary');
|
|
||||||
}, [activeRoverId, primaryRoverId, secondaryRoverId]);
|
|
||||||
|
|
||||||
const primaryRover = primaryRoverId
|
|
||||||
? rotationPool.find((entry) => entry.rover?.id === primaryRoverId)?.rover || null
|
|
||||||
: null;
|
|
||||||
const secondaryRover = secondaryRoverId
|
|
||||||
? rotationPool.find((entry) => entry.rover?.id === secondaryRoverId)?.rover || null
|
|
||||||
: null;
|
|
||||||
|
|
||||||
const activeSnapshot = !canSpectateVideo && activeRover ? snapshotFeeds[activeRover.id] || null : null;
|
const activeSnapshot = !canSpectateVideo && activeRover ? snapshotFeeds[activeRover.id] || null : null;
|
||||||
const activeVideo = canSpectateVideo && activeRover ? videoSources[activeRover.id] || null : null;
|
const activeVideo = canSpectateVideo && activeRover ? videoSources[activeRover.id] || null : null;
|
||||||
const primaryVideo = canSpectateVideo && primaryRover ? videoSources[primaryRover.id] || null : null;
|
|
||||||
const secondaryVideo = canSpectateVideo && secondaryRover ? videoSources[secondaryRover.id] || null : null;
|
|
||||||
const activeAudio = activeRover ? audioSources[`${activeRover.id}-audio`] || null : null;
|
const activeAudio = activeRover ? audioSources[`${activeRover.id}-audio`] || null : null;
|
||||||
const activeFrame = activeRover ? frames[activeRover.id] || null : null;
|
const activeFrame = activeRover ? frames[activeRover.id] || null : null;
|
||||||
const primaryFrame = primaryRover ? frames[primaryRover.id] || null : null;
|
|
||||||
const secondaryFrame = secondaryRover ? frames[secondaryRover.id] || null : null;
|
|
||||||
const driverLabel = activeRover ? formatDriverLabel({ roverId: activeRover.id, session }) : null;
|
const driverLabel = activeRover ? formatDriverLabel({ roverId: activeRover.id, session }) : null;
|
||||||
|
|
||||||
if (inLockdown) {
|
if (inLockdown) {
|
||||||
@@ -409,44 +348,30 @@ function MiniSummaryContent() {
|
|||||||
<FitViewportFrame>
|
<FitViewportFrame>
|
||||||
{canSpectateVideo ? (
|
{canSpectateVideo ? (
|
||||||
<div className="relative h-full w-full">
|
<div className="relative h-full w-full">
|
||||||
{primaryRover ? (
|
{rotationPool.map((entry) => {
|
||||||
<div
|
const rover = entry.rover;
|
||||||
className={`absolute inset-0 ${visibleSlot === 'primary' ? 'opacity-100' : 'opacity-0 pointer-events-none'}`}
|
const isActive = activeRover?.id === rover.id;
|
||||||
>
|
return (
|
||||||
<VideoTile
|
<div
|
||||||
sessionInfo={primaryVideo}
|
key={rover.id}
|
||||||
videoMode="whep"
|
className={`absolute inset-0 ${isActive ? 'opacity-100' : 'opacity-0 pointer-events-none'}`}
|
||||||
snapshotFeed={null}
|
>
|
||||||
audioSessionInfo={visibleSlot === 'primary' ? activeAudio : null}
|
<VideoTile
|
||||||
forceMute={visibleSlot !== 'primary'}
|
sessionInfo={videoSources[rover.id] || null}
|
||||||
label={primaryRover.name || primaryRover.id}
|
videoMode="whep"
|
||||||
telemetryFrame={primaryFrame}
|
snapshotFeed={null}
|
||||||
batteryConfig={primaryRover.battery}
|
audioSessionInfo={isActive ? activeAudio : null}
|
||||||
layoutFormat="mobile"
|
forceMute={!isActive}
|
||||||
hudVariant="none"
|
label={rover.name || rover.id}
|
||||||
fitParent
|
telemetryFrame={frames[rover.id] || null}
|
||||||
/>
|
batteryConfig={rover.battery}
|
||||||
</div>
|
layoutFormat="mobile"
|
||||||
) : null}
|
hudVariant="none"
|
||||||
{secondaryRover ? (
|
fitParent
|
||||||
<div
|
/>
|
||||||
className={`absolute inset-0 ${visibleSlot === 'secondary' ? 'opacity-100' : 'opacity-0 pointer-events-none'}`}
|
</div>
|
||||||
>
|
);
|
||||||
<VideoTile
|
})}
|
||||||
sessionInfo={secondaryVideo}
|
|
||||||
videoMode="whep"
|
|
||||||
snapshotFeed={null}
|
|
||||||
audioSessionInfo={visibleSlot === 'secondary' ? activeAudio : null}
|
|
||||||
forceMute={visibleSlot !== 'secondary'}
|
|
||||||
label={secondaryRover.name || secondaryRover.id}
|
|
||||||
telemetryFrame={secondaryFrame}
|
|
||||||
batteryConfig={secondaryRover.battery}
|
|
||||||
layoutFormat="mobile"
|
|
||||||
hudVariant="none"
|
|
||||||
fitParent
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
) : null}
|
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<VideoTile
|
<VideoTile
|
||||||
|
|||||||
Reference in New Issue
Block a user