From 434de4132ea2c86eef7720517254edd710a88617 Mon Sep 17 00:00:00 2001 From: ganfra Date: Wed, 5 Jul 2023 12:56:39 +0200 Subject: [PATCH] Room: dispatch getRooms on background thread --- .../android/libraries/matrix/impl/RustMatrixClient.kt | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/RustMatrixClient.kt b/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/RustMatrixClient.kt index 84a5a38784..85aef441d2 100644 --- a/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/RustMatrixClient.kt +++ b/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/RustMatrixClient.kt @@ -55,6 +55,7 @@ import io.element.android.services.toolbox.api.systemclock.SystemClock import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.cancel +import kotlinx.coroutines.delay import kotlinx.coroutines.flow.filter import kotlinx.coroutines.flow.first import kotlinx.coroutines.flow.firstOrNull @@ -150,12 +151,10 @@ class RustMatrixClient constructor( ) } - private suspend fun pairOfRoom(roomId: RoomId): Pair? { - Timber.v("Resume get pair of room for $roomId") + private suspend fun pairOfRoom(roomId: RoomId): Pair? = withContext(dispatchers.io) { val cachedRoomListItem = roomListService.roomOrNull(roomId.value) val fullRoom = cachedRoomListItem?.fullRoom() - Timber.v("Finish get pair of room for $roomId") - return if (cachedRoomListItem == null || fullRoom == null) { + if (cachedRoomListItem == null || fullRoom == null) { null } else { Pair(cachedRoomListItem, fullRoom)