1.0 KiB
1.0 KiB
2024-12-18 16:45:00 - Implement Game Persistence on Reload
Description
Updated LobbyManager.tsx to ensure that when a user reloads the page and automatically rejoins a room, the active game state (initialGameState) is correctly retrieved from the server and passed to the game view components.
Key Changes
- Component:
LobbyManager.tsx - Functionality:
- Added
initialGameStatestate. - Updated
join_roomandrejoin_roomresponse handling to capturegameStateif present. - Passed
initialGameStateto theGameRoomcomponent.
- Added
Impact
- User Experience: If a user is in the middle of a game (battlefield phase) and refreshes the browser, they will now immediately see the battlefield state instead of a loading or broken screen, ensuring continuity.
- Data Flow:
GameRoomuses this prop to initialize its localgameStatebefore the first socket update event arrives.
Status
- Implementation logic complete.
- User testing required (refresh page during active game).