Skip to content

[Feature] Clean up session and players when leaving lobby #34

Closed
8 tasks
odaakj opened this issue Mar 21, 2026 · 0 comments · Fixed by #35
Closed
8 tasks

[Feature] Clean up session and players when leaving lobby #34

odaakj opened this issue Mar 21, 2026 · 0 comments · Fixed by #35
Assignees
Labels

Comments

@odaakj
Copy link
Collaborator

odaakj commented Mar 21, 2026

Description

Currently, sessions and players are not properly removed from Firebase when users leave the lobby. This leads to:

  • Sessions persisting even after the host exits the lobby
  • Players remaining in a session after navigating away, allowing duplicate joins

This issue aims to ensure proper cleanup of sessions and players when leaving the lobby.

Requirements covered

  • Ensure session lifecycle is correctly managed
  • Ensure player list reflects only active participants

Acceptance criteria

Host leaves lobby

When the host exits the lobby:

  • The entire session is deleted from Firestore
  • All associated players are removed

Player leaves lobby

When a non-host player exits the lobby:

  • The player is removed from Sessions/{sessionId}/Players
  • The session remains active

Navigation handling

Leaving the lobby via:

  • Back button
  • Navigation to another screen
  • Should trigger cleanup logic

Prevent duplicate players

A player should not be able to:

  • Join the same session multiple times by navigating back and rejoining

Technical tasks

  • Add removePlayerFromSession(...) to FirebaseGateway
  • Add deleteSession(...) to FirebaseGateway
  • Implement both in FirestoreSessionRepository
  • Implement both in AndroidFirebaseGateway and NoOpFirebaseGateway
  • Add leaveLobby(...) method in LobbyService
  • Pass playerId and isHost to LobbyView / LobbyState
  • Update LobbyController.onBackFromLobby(...) to trigger cleanup
  • Ensure cleanup is only triggered once (avoid duplicate calls)

Related requirement

No response

Architecture layer

None

Sign in to join this conversation on GitHub.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant