Merge pull request #1376 from vector-im/feature/fga/fix_room_member_infinite_loop
Fix room member infinite loop
This commit is contained in:
commit
df565ddd9b
1 changed files with 14 additions and 9 deletions
|
|
@ -44,8 +44,8 @@ import io.element.android.libraries.matrix.api.timeline.item.event.EventType
|
||||||
import io.element.android.libraries.matrix.impl.core.toProgressWatcher
|
import io.element.android.libraries.matrix.impl.core.toProgressWatcher
|
||||||
import io.element.android.libraries.matrix.impl.media.MediaUploadHandlerImpl
|
import io.element.android.libraries.matrix.impl.media.MediaUploadHandlerImpl
|
||||||
import io.element.android.libraries.matrix.impl.media.map
|
import io.element.android.libraries.matrix.impl.media.map
|
||||||
import io.element.android.libraries.matrix.impl.poll.toInner
|
|
||||||
import io.element.android.libraries.matrix.impl.notificationsettings.RustNotificationSettingsService
|
import io.element.android.libraries.matrix.impl.notificationsettings.RustNotificationSettingsService
|
||||||
|
import io.element.android.libraries.matrix.impl.poll.toInner
|
||||||
import io.element.android.libraries.matrix.impl.room.location.toInner
|
import io.element.android.libraries.matrix.impl.room.location.toInner
|
||||||
import io.element.android.libraries.matrix.impl.timeline.RustMatrixTimeline
|
import io.element.android.libraries.matrix.impl.timeline.RustMatrixTimeline
|
||||||
import io.element.android.libraries.matrix.impl.util.destroyAll
|
import io.element.android.libraries.matrix.impl.util.destroyAll
|
||||||
|
|
@ -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
|
||||||
|
|
@ -187,18 +188,22 @@ class RustMatrixRoom(
|
||||||
_membersStateFlow.value = MatrixRoomMembersState.Pending(prevRoomMembers = currentMembers)
|
_membersStateFlow.value = MatrixRoomMembersState.Pending(prevRoomMembers = currentMembers)
|
||||||
var rustMembers: List<RoomMember>? = null
|
var rustMembers: List<RoomMember>? = null
|
||||||
try {
|
try {
|
||||||
rustMembers = buildList {
|
rustMembers = innerRoom.members().use { membersIterator ->
|
||||||
while (true) {
|
buildList {
|
||||||
// Loading the whole iterator as a stop-gap measure.
|
while (true) {
|
||||||
// We should probably implement some sort of paging in the future.
|
// Loading the whole membersIterator as a stop-gap measure.
|
||||||
addAll(innerRoom.members().nextChunk(1000u) ?: break)
|
// We should probably implement some sort of paging in the future.
|
||||||
|
yield()
|
||||||
|
addAll(membersIterator.nextChunk(1000u) ?: break)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
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 (cancellationException: CancellationException) {
|
} catch (exception: CancellationException) {
|
||||||
throw 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)
|
||||||
Result.failure(exception)
|
Result.failure(exception)
|
||||||
|
|
@ -466,7 +471,7 @@ class RustMatrixRoom(
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun messageEventContentFromParts(body: String, htmlBody: String?): RoomMessageEventContentWithoutRelation =
|
private fun messageEventContentFromParts(body: String, htmlBody: String?): RoomMessageEventContentWithoutRelation =
|
||||||
if(htmlBody != null) {
|
if (htmlBody != null) {
|
||||||
messageEventContentFromHtml(body, htmlBody)
|
messageEventContentFromHtml(body, htmlBody)
|
||||||
} else {
|
} else {
|
||||||
messageEventContentFromMarkdown(body)
|
messageEventContentFromMarkdown(body)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue