mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-03 06:55:41 +00:00
Reload member list after moderation actions (#5268)
* Reload member list after moderation actions The previous `runActionAndWaitForMembershipChange` logic wasn't really doing anything, as the modified flow was never used. * Make sure we always set the value in the member list state flow, even if the underlying coroutine scope is no longer there. With `emit`, the `Ready` state was not emitted if the member list was loaded way too fast.
This commit is contained in:
committed by
GitHub
parent
b2d4985205
commit
d4d57b1e21
+7
-7
@@ -38,6 +38,7 @@ import kotlinx.collections.immutable.ImmutableMap
|
||||
import kotlinx.collections.immutable.persistentMapOf
|
||||
import kotlinx.collections.immutable.toImmutableList
|
||||
import kotlinx.collections.immutable.toPersistentMap
|
||||
import kotlinx.coroutines.flow.collectLatest
|
||||
import kotlinx.coroutines.flow.distinctUntilChanged
|
||||
import kotlinx.coroutines.flow.first
|
||||
import kotlinx.coroutines.flow.launchIn
|
||||
@@ -66,11 +67,6 @@ 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)
|
||||
@@ -81,8 +77,12 @@ class RoomMemberListPresenter @Inject constructor(
|
||||
}
|
||||
|
||||
// Update the room members when the screen is loaded or the active member count changes
|
||||
LaunchedEffect(activeRoomMemberCount) {
|
||||
room.updateMembers()
|
||||
LaunchedEffect(Unit) {
|
||||
room.roomInfoFlow.map { it.activeMembersCount }
|
||||
.distinctUntilChanged()
|
||||
.collectLatest {
|
||||
room.updateMembers()
|
||||
}
|
||||
}
|
||||
|
||||
LaunchedEffect(membersState, roomMemberIdentityStates) {
|
||||
|
||||
-3
@@ -116,9 +116,6 @@ class RoomMemberListPresenterTest {
|
||||
}
|
||||
}
|
||||
|
||||
// Wait for the update to be processed
|
||||
skipItems(1)
|
||||
|
||||
// Update the room members state as `Room.updateMembers()` would have done with the actual implementation
|
||||
room.givenRoomMembersState(RoomMembersState.Ready(persistentListOf()))
|
||||
// Wait for another update
|
||||
|
||||
Reference in New Issue
Block a user