Skip to content

Commit ec2e448

Browse files
committed
Change the list of active rooms to a set so you can't have the same instance twice, remove outdated docs
1 parent beb2952 commit ec2e448

File tree

1 file changed

+2
-4
lines changed
  • services/appnavstate/api/src/main/kotlin/io/element/android/services/appnavstate/api

1 file changed

+2
-4
lines changed

services/appnavstate/api/src/main/kotlin/io/element/android/services/appnavstate/api/ActiveRoomsHolder.kt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,16 @@ import javax.inject.Inject
1717

1818
/**
1919
* Holds the active rooms for a given session so they can be reused instead of instantiating new ones.
20-
*
21-
* This works as a FILO (First In Last Out) stack, meaning that the last room added for a session will be the first one to be removed.
2220
*/
2321
@SingleIn(AppScope::class)
2422
class ActiveRoomsHolder @Inject constructor() {
25-
private val rooms = ConcurrentHashMap<SessionId, MutableList<JoinedRoom>>()
23+
private val rooms = ConcurrentHashMap<SessionId, MutableSet<JoinedRoom>>()
2624

2725
/**
2826
* Adds a new held room for the given sessionId.
2927
*/
3028
fun addRoom(room: JoinedRoom) {
31-
val roomsForSessionId = rooms.getOrPut(key = room.sessionId, defaultValue = { mutableListOf() })
29+
val roomsForSessionId = rooms.getOrPut(key = room.sessionId, defaultValue = { mutableSetOf() })
3230
if (roomsForSessionId.none { it.roomId == room.roomId }) {
3331
// We don't want to add the same room multiple times
3432
roomsForSessionId.add(room)

0 commit comments

Comments
 (0)