fix(eodArena): simplify sidebar handling for mobile in landscape orientation
This commit is contained in:
parent
0eba54b8b8
commit
a0c9fe9e8e
1 changed files with 3 additions and 12 deletions
|
|
@ -17,24 +17,15 @@ export function EodArena({
|
|||
const [refreshKey, setRefreshKey] = useState(0);
|
||||
const [playing, setPlaying] = useState(false);
|
||||
const [selectedDifficulty, setSelectedDifficulty] = useState<EodDifficulty>("training");
|
||||
const { isMobile, setOpen, setOpenMobile } = useSidebar();
|
||||
const { isMobile, setOpenMobile } = useSidebar();
|
||||
const activeTeams = useRealtimePresence("eod", playing, true);
|
||||
const onPhaseChange = useCallback((phase: "ready" | "playing" | "over") => {
|
||||
setPlaying(phase === "playing");
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
const landscapeQuery = window.matchMedia("(orientation: landscape)");
|
||||
const hideSidebarForLandscapeGame = () => {
|
||||
if (!playing || !landscapeQuery.matches) return;
|
||||
if (isMobile) setOpenMobile(false);
|
||||
else setOpen(false);
|
||||
};
|
||||
|
||||
hideSidebarForLandscapeGame();
|
||||
landscapeQuery.addEventListener("change", hideSidebarForLandscapeGame);
|
||||
return () => landscapeQuery.removeEventListener("change", hideSidebarForLandscapeGame);
|
||||
}, [isMobile, playing, setOpen, setOpenMobile]);
|
||||
if (playing && isMobile) setOpenMobile(false);
|
||||
}, [isMobile, playing, setOpenMobile]);
|
||||
|
||||
return (
|
||||
<div className="flex flex-col items-center gap-6">
|
||||
|
|
|
|||
Loading…
Reference in a new issue