mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-03 16:10:00 +00:00
Room: dispatch getRooms on background thread
This commit is contained in:
+3
-4
@@ -55,6 +55,7 @@ import io.element.android.services.toolbox.api.systemclock.SystemClock
|
|||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.cancel
|
import kotlinx.coroutines.cancel
|
||||||
|
import kotlinx.coroutines.delay
|
||||||
import kotlinx.coroutines.flow.filter
|
import kotlinx.coroutines.flow.filter
|
||||||
import kotlinx.coroutines.flow.first
|
import kotlinx.coroutines.flow.first
|
||||||
import kotlinx.coroutines.flow.firstOrNull
|
import kotlinx.coroutines.flow.firstOrNull
|
||||||
@@ -150,12 +151,10 @@ class RustMatrixClient constructor(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private suspend fun pairOfRoom(roomId: RoomId): Pair<RoomListItem, Room>? {
|
private suspend fun pairOfRoom(roomId: RoomId): Pair<RoomListItem, Room>? = withContext(dispatchers.io) {
|
||||||
Timber.v("Resume get pair of room for $roomId")
|
|
||||||
val cachedRoomListItem = roomListService.roomOrNull(roomId.value)
|
val cachedRoomListItem = roomListService.roomOrNull(roomId.value)
|
||||||
val fullRoom = cachedRoomListItem?.fullRoom()
|
val fullRoom = cachedRoomListItem?.fullRoom()
|
||||||
Timber.v("Finish get pair of room for $roomId")
|
if (cachedRoomListItem == null || fullRoom == null) {
|
||||||
return if (cachedRoomListItem == null || fullRoom == null) {
|
|
||||||
null
|
null
|
||||||
} else {
|
} else {
|
||||||
Pair(cachedRoomListItem, fullRoom)
|
Pair(cachedRoomListItem, fullRoom)
|
||||||
|
|||||||
Reference in New Issue
Block a user