Fix warning and yield
This commit is contained in:
parent
0bd6ba0984
commit
c3df84cb7b
1 changed files with 6 additions and 5 deletions
|
|
@ -59,6 +59,7 @@ import kotlinx.coroutines.flow.MutableStateFlow
|
||||||
import kotlinx.coroutines.flow.StateFlow
|
import kotlinx.coroutines.flow.StateFlow
|
||||||
import kotlinx.coroutines.flow.asStateFlow
|
import kotlinx.coroutines.flow.asStateFlow
|
||||||
import kotlinx.coroutines.withContext
|
import kotlinx.coroutines.withContext
|
||||||
|
import kotlinx.coroutines.yield
|
||||||
import org.matrix.rustcomponents.sdk.RequiredState
|
import org.matrix.rustcomponents.sdk.RequiredState
|
||||||
import org.matrix.rustcomponents.sdk.Room
|
import org.matrix.rustcomponents.sdk.Room
|
||||||
import org.matrix.rustcomponents.sdk.RoomListItem
|
import org.matrix.rustcomponents.sdk.RoomListItem
|
||||||
|
|
@ -192,6 +193,7 @@ class RustMatrixRoom(
|
||||||
while (true) {
|
while (true) {
|
||||||
// Loading the whole membersIterator as a stop-gap measure.
|
// Loading the whole membersIterator as a stop-gap measure.
|
||||||
// We should probably implement some sort of paging in the future.
|
// We should probably implement some sort of paging in the future.
|
||||||
|
yield()
|
||||||
addAll(membersIterator.nextChunk(1000u) ?: break)
|
addAll(membersIterator.nextChunk(1000u) ?: break)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -199,13 +201,12 @@ class RustMatrixRoom(
|
||||||
val mappedMembers = rustMembers.parallelMap(RoomMemberMapper::map)
|
val mappedMembers = rustMembers.parallelMap(RoomMemberMapper::map)
|
||||||
_membersStateFlow.value = MatrixRoomMembersState.Ready(mappedMembers)
|
_membersStateFlow.value = MatrixRoomMembersState.Ready(mappedMembers)
|
||||||
Result.success(Unit)
|
Result.success(Unit)
|
||||||
|
} catch (exception: CancellationException) {
|
||||||
|
_membersStateFlow.value = MatrixRoomMembersState.Error(prevRoomMembers = currentMembers, failure = exception)
|
||||||
|
throw exception
|
||||||
} catch (exception: Exception) {
|
} catch (exception: Exception) {
|
||||||
_membersStateFlow.value = MatrixRoomMembersState.Error(prevRoomMembers = currentMembers, failure = exception)
|
_membersStateFlow.value = MatrixRoomMembersState.Error(prevRoomMembers = currentMembers, failure = exception)
|
||||||
if (exception is CancellationException) {
|
Result.failure(exception)
|
||||||
throw exception
|
|
||||||
} else {
|
|
||||||
Result.failure(exception)
|
|
||||||
}
|
|
||||||
} finally {
|
} finally {
|
||||||
rustMembers?.destroyAll()
|
rustMembers?.destroyAll()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue