Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update member list after changing member roles #2591

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/2590.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Update member list after changing member roles and when the room member list is opened.
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,13 @@ class RoomMemberListDataSource @Inject constructor(
) {
suspend fun search(query: String): List<RoomMember> = withContext(coroutineDispatchers.io) {
val roomMembersState = room.membersStateFlow.value
val roomMembers = roomMembersState.roomMembers().orEmpty()
val activeRoomMembers = roomMembersState.roomMembers()
?.filter { it.membership.isActive() }
.orEmpty()
val filteredMembers = if (query.isBlank()) {
roomMembers
activeRoomMembers
} else {
roomMembers.filter { member ->
activeRoomMembers.filter { member ->
member.userId.value.contains(query, ignoreCase = true) ||
member.displayName?.contains(query, ignoreCase = true).orFalse()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ class RoomMemberListPresenter @AssistedInject constructor(
remember { roomMembersModerationPresenter.dummyState() }
}

// Ensure we load the latest data when entering this screen
LaunchedEffect(Unit) {
room.updateMembers()
}

LaunchedEffect(membersState) {
if (membersState is MatrixRoomMembersState.Unknown) {
return@LaunchedEffect
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,8 @@ class ChangeRolesPresenter @AssistedInject constructor(
}
.onSuccess {
saveState.value = AsyncAction.Success(Unit)
// Asynchronously reload the room members
launch { room.updateMembers() }
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ enum class RoomMembershipState {
INVITE,
JOIN,
KNOCK,
LEAVE
LEAVE;

fun isActive(): Boolean = this == JOIN || this == INVITE
}

/**
Expand Down
Loading