From 1dcd45930c3345345dcb940d1bf0022da71c0d88 Mon Sep 17 00:00:00 2001 From: jessy-david-dev Date: Wed, 15 Apr 2026 18:34:02 +0200 Subject: [PATCH] fix(lobby): optimistic toggle for search allowed, fixes display always showing blocked --- app/components/LobbyScreen.tsx | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/app/components/LobbyScreen.tsx b/app/components/LobbyScreen.tsx index a25004a..a81f766 100644 --- a/app/components/LobbyScreen.tsx +++ b/app/components/LobbyScreen.tsx @@ -1,6 +1,6 @@ "use client"; -import { useState } from "react"; +import { useState, useEffect } from "react"; import type { Room } from "../api/rooms/route"; type LobbyScreenProps = { @@ -47,6 +47,8 @@ export function LobbyScreen({ const isHost = room.players.find((p) => p.id === playerId)?.isHost ?? false; const [copied, setCopied] = useState(false); const [blurred, setBlurred] = useState(true); + const [searchAllowed, setSearchAllowed] = useState(room.searchAllowed); + useEffect(() => { setSearchAllowed(room.searchAllowed); }, [room.searchAllowed]); function copyCode() { navigator.clipboard.writeText(room.code).then(() => { @@ -210,14 +212,14 @@ export function LobbyScreen({ @@ -225,13 +227,13 @@ export function LobbyScreen({ {!isHost && (
🔍 Recherche Ctrl+F - {room.searchAllowed ? "AutorisĂ©e" : "BloquĂ©e"} + {searchAllowed ? "AutorisĂ©e" : "BloquĂ©e"}
)}