Skip to content

Commit c3df84c

Browse files
committed
Fix warning and yield
1 parent 0bd6ba0 commit c3df84c

File tree

1 file changed

+6
-5
lines changed
  • libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/room

1 file changed

+6
-5
lines changed

libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/room/RustMatrixRoom.kt

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ import kotlinx.coroutines.flow.MutableStateFlow
5959
import kotlinx.coroutines.flow.StateFlow
6060
import kotlinx.coroutines.flow.asStateFlow
6161
import kotlinx.coroutines.withContext
62+
import kotlinx.coroutines.yield
6263
import org.matrix.rustcomponents.sdk.RequiredState
6364
import org.matrix.rustcomponents.sdk.Room
6465
import org.matrix.rustcomponents.sdk.RoomListItem
@@ -192,20 +193,20 @@ class RustMatrixRoom(
192193
while (true) {
193194
// Loading the whole membersIterator as a stop-gap measure.
194195
// We should probably implement some sort of paging in the future.
196+
yield()
195197
addAll(membersIterator.nextChunk(1000u) ?: break)
196198
}
197199
}
198200
}
199201
val mappedMembers = rustMembers.parallelMap(RoomMemberMapper::map)
200202
_membersStateFlow.value = MatrixRoomMembersState.Ready(mappedMembers)
201203
Result.success(Unit)
204+
} catch (exception: CancellationException) {
205+
_membersStateFlow.value = MatrixRoomMembersState.Error(prevRoomMembers = currentMembers, failure = exception)
206+
throw exception
202207
} catch (exception: Exception) {
203208
_membersStateFlow.value = MatrixRoomMembersState.Error(prevRoomMembers = currentMembers, failure = exception)
204-
if (exception is CancellationException) {
205-
throw exception
206-
} else {
207-
Result.failure(exception)
208-
}
209+
Result.failure(exception)
209210
} finally {
210211
rustMembers?.destroyAll()
211212
}

0 commit comments

Comments
 (0)