@@ -44,8 +44,8 @@ import io.element.android.libraries.matrix.api.timeline.item.event.EventType
4444import io.element.android.libraries.matrix.impl.core.toProgressWatcher
4545import io.element.android.libraries.matrix.impl.media.MediaUploadHandlerImpl
4646import io.element.android.libraries.matrix.impl.media.map
47- import io.element.android.libraries.matrix.impl.poll.toInner
4847import io.element.android.libraries.matrix.impl.notificationsettings.RustNotificationSettingsService
48+ import io.element.android.libraries.matrix.impl.poll.toInner
4949import io.element.android.libraries.matrix.impl.room.location.toInner
5050import io.element.android.libraries.matrix.impl.timeline.RustMatrixTimeline
5151import io.element.android.libraries.matrix.impl.util.destroyAll
@@ -187,21 +187,25 @@ class RustMatrixRoom(
187187 _membersStateFlow .value = MatrixRoomMembersState .Pending (prevRoomMembers = currentMembers)
188188 var rustMembers: List <RoomMember >? = null
189189 try {
190- rustMembers = buildList {
191- while (true ) {
192- // Loading the whole iterator as a stop-gap measure.
193- // We should probably implement some sort of paging in the future.
194- addAll(innerRoom.members().nextChunk(1000u ) ? : break )
190+ rustMembers = innerRoom.members().use { membersIterator ->
191+ buildList {
192+ while (true ) {
193+ // Loading the whole membersIterator as a stop-gap measure.
194+ // We should probably implement some sort of paging in the future.
195+ addAll(membersIterator.nextChunk(1000u ) ? : break )
196+ }
195197 }
196198 }
197199 val mappedMembers = rustMembers.parallelMap(RoomMemberMapper ::map)
198200 _membersStateFlow .value = MatrixRoomMembersState .Ready (mappedMembers)
199201 Result .success(Unit )
200- } catch (cancellationException: CancellationException ) {
201- throw cancellationException
202202 } catch (exception: Exception ) {
203203 _membersStateFlow .value = MatrixRoomMembersState .Error (prevRoomMembers = currentMembers, failure = exception)
204- Result .failure(exception)
204+ if (exception is CancellationException ) {
205+ throw exception
206+ } else {
207+ Result .failure(exception)
208+ }
205209 } finally {
206210 rustMembers?.destroyAll()
207211 }
@@ -466,7 +470,7 @@ class RustMatrixRoom(
466470 }
467471
468472 private fun messageEventContentFromParts (body : String , htmlBody : String? ): RoomMessageEventContentWithoutRelation =
469- if (htmlBody != null ) {
473+ if (htmlBody != null ) {
470474 messageEventContentFromHtml(body, htmlBody)
471475 } else {
472476 messageEventContentFromMarkdown(body)
0 commit comments