Remove previously used id filtering from RoomSyncSubscriber (#5985)
This is done in the SDK, doing it in the client was a source of issues.
This commit is contained in:
parent
d3537bdd0f
commit
1f86a4d2c4
1 changed files with 4 additions and 16 deletions
|
|
@ -21,18 +21,14 @@ class RoomSyncSubscriber(
|
|||
private val roomListService: RoomListService,
|
||||
private val dispatchers: CoroutineDispatchers,
|
||||
) {
|
||||
private val subscribedRoomIds = mutableSetOf<RoomId>()
|
||||
private val mutex = Mutex()
|
||||
|
||||
suspend fun subscribe(roomId: RoomId) {
|
||||
mutex.withLock {
|
||||
withContext(dispatchers.io) {
|
||||
try {
|
||||
if (!isSubscribedTo(roomId)) {
|
||||
Timber.d("Subscribing to room $roomId}")
|
||||
roomListService.subscribeToRooms(listOf(roomId.value))
|
||||
}
|
||||
subscribedRoomIds.add(roomId)
|
||||
Timber.d("Subscribing to room $roomId}")
|
||||
roomListService.subscribeToRooms(listOf(roomId.value))
|
||||
} catch (exception: Exception) {
|
||||
Timber.e(exception, "Failed to subscribe to room $roomId")
|
||||
}
|
||||
|
|
@ -43,12 +39,8 @@ class RoomSyncSubscriber(
|
|||
suspend fun batchSubscribe(roomIds: List<RoomId>) = mutex.withLock {
|
||||
withContext(dispatchers.io) {
|
||||
try {
|
||||
val roomIdsToSubscribeTo = roomIds.filterNot { isSubscribedTo(it) }
|
||||
if (roomIdsToSubscribeTo.isNotEmpty()) {
|
||||
Timber.d("Subscribing to rooms: $roomIds")
|
||||
roomListService.subscribeToRooms(roomIdsToSubscribeTo.map { it.value })
|
||||
subscribedRoomIds.addAll(roomIds)
|
||||
}
|
||||
Timber.d("Subscribing to rooms: $roomIds")
|
||||
roomListService.subscribeToRooms(roomIds.map { it.value })
|
||||
} catch (cancellationException: CancellationException) {
|
||||
throw cancellationException
|
||||
} catch (exception: Exception) {
|
||||
|
|
@ -56,8 +48,4 @@ class RoomSyncSubscriber(
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun isSubscribedTo(roomId: RoomId): Boolean {
|
||||
return subscribedRoomIds.contains(roomId)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue