Reload room member list when active members count changes (#5129)

This commit is contained in:
Jorge Martin Espinosa 2025-08-06 12:37:52 +02:00 committed by GitHub
parent 955263bee1
commit 2a42a71490
2 changed files with 70 additions and 2 deletions

View file

@ -38,8 +38,10 @@ import kotlinx.collections.immutable.ImmutableMap
import kotlinx.collections.immutable.persistentMapOf
import kotlinx.collections.immutable.toImmutableList
import kotlinx.collections.immutable.toPersistentMap
import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.withContext
import javax.inject.Inject
@ -64,6 +66,11 @@ class RoomMemberListPresenter @Inject constructor(
val syncUpdateFlow = room.syncUpdateFlow.collectAsState()
val canInvite by room.canInviteAsState(syncUpdateFlow.value)
val roomModerationState = roomMembersModerationPresenter.present()
val activeRoomMemberCount by produceState(0L) {
room.roomInfoFlow.map { it.activeMembersCount }
.distinctUntilChanged()
.collect { value = it }
}
val roomMemberIdentityStates by produceState(persistentMapOf<UserId, IdentityState>()) {
room.roomMemberIdentityStateChange(waitForEncryption = true)
@ -73,8 +80,8 @@ class RoomMemberListPresenter @Inject constructor(
.launchIn(this)
}
// Ensure we load the latest data when entering this screen
LaunchedEffect(Unit) {
// Update the room members when the screen is loaded or the active member count changes
LaunchedEffect(activeRoomMemberCount) {
room.updateMembers()
}