mirror of
https://github.com/legop3/MultiRoombaRover.git
synced 2026-11-14 18:58:49 -05:00
17 lines
792 B
React
17 lines
792 B
React
// Shared spectator replay handling keeps disabled pages from retaining old popups.
|
|
import { useEffect } from 'react';
|
|
import { useSessionActions, useSessionSelector } from '../../context/SessionContext.jsx';
|
|
import ReplayReadyPopup from '../ReplaySourcesPanel/ReplayReadyPopup.jsx';
|
|
|
|
export default function SpectatorReplayPopup({ enabled, ready }) {
|
|
const replay = useSessionSelector((state) => state.latestReplay);
|
|
const { clearLatestReplay } = useSessionActions();
|
|
|
|
useEffect(() => {
|
|
// Consume arrivals while disabled so enabling popups only shows future replays.
|
|
if (ready && !enabled && replay) clearLatestReplay();
|
|
}, [ready, enabled, replay, clearLatestReplay]);
|
|
|
|
return ready && enabled ? <ReplayReadyPopup replay={replay} onClose={clearLatestReplay} /> : null;
|
|
}
|