Skip to content

Commit

Permalink
spectator menu bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ItsSammyM committed Oct 10, 2024
1 parent a35651c commit c311f80
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 15 deletions.
2 changes: 1 addition & 1 deletion client/src/menu/Anchor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export default function Anchor(props: Readonly<{
const [mobile, setMobile] = useState<boolean>(false);

useEffect(() => {
const onResize = () => setMobile(window.innerWidth <= MOBILE_MAX_WIDTH_PX)
const onResize = () => {setMobile(window.innerWidth <= MOBILE_MAX_WIDTH_PX)}
onResize();

window.addEventListener("resize", onResize);
Expand Down
2 changes: 1 addition & 1 deletion client/src/menu/game/HeaderMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ function VerdictButton(props: Readonly<{ verdict: Verdict }>) {
</Button>
}

function MenuButtons(props: Readonly<{ chatMenuNotification: boolean }>): ReactElement {
function MenuButtons(props: Readonly<{ chatMenuNotification: boolean }>): ReactElement | null {
const roleState = usePlayerState(
clientState => clientState.roleState,
["yourRoleState"]
Expand Down
26 changes: 14 additions & 12 deletions client/src/menu/spectator/SpectatorGameScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import ChatMenu from "../game/gameScreenContent/ChatMenu";
import PlayerListMenu from "../game/gameScreenContent/PlayerListMenu";
import GraveyardMenu from "../game/gameScreenContent/GraveyardMenu";
import HeaderMenu from "../game/HeaderMenu";
import { MenuController, ContentMenu, useMenuController } from "../game/GameScreen";
import { MenuController, ContentMenu, useMenuController, MenuControllerContext } from "../game/GameScreen";
import { MobileContext } from "../Anchor";


Expand Down Expand Up @@ -56,18 +56,20 @@ export default function SpectatorGameScreen(): ReactElement {


return (
<div className="game-screen spectator-game-screen">
<div className="header">
<HeaderMenu chatMenuNotification={false}/>
<MenuControllerContext.Provider value={contentController}>
<div className="game-screen spectator-game-screen">
<div className="header">
<HeaderMenu chatMenuNotification={false}/>
</div>
{showStartedScreen
? <PhaseStartedScreen/>
: <div className="content">
{contentController.menuOpen(ContentMenu.ChatMenu) && <ChatMenu/>}
{contentController.menuOpen(ContentMenu.PlayerListMenu) && <PlayerListMenu/>}
{contentController.menuOpen(ContentMenu.GraveyardMenu) && <GraveyardMenu/>}
</div>}
</div>
{showStartedScreen
? <PhaseStartedScreen/>
: <div className="content">
{contentController.menuOpen(ContentMenu.ChatMenu) && <ChatMenu/>}
{contentController.menuOpen(ContentMenu.PlayerListMenu) && <PlayerListMenu/>}
{contentController.menuOpen(ContentMenu.GraveyardMenu) && <GraveyardMenu/>}
</div>}
</div>
</MenuControllerContext.Provider>
);

}
2 changes: 1 addition & 1 deletion server/src/listener.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ impl Listener{
}

pub fn on_disconnect(&mut self, connection: Connection) -> Result<(), &'static str> {
self.set_player_outside_lobby(connection.get_address(), true);
let _ = self.delete_player(connection.get_address(), true);
Ok(())
}

Expand Down

0 comments on commit c311f80

Please sign in to comment.