Fix a problem with filtering 3pid invite.

We were using the whole 3pid invite if they were not all filtered.
Also double filtering on RoomThirdPartyInviteContent type is not necessary
This commit is contained in:
Benoit Marty 2021-11-04 15:59:20 +01:00 committed by Benoit Marty
parent 345dac4a3b
commit 41ab117182

View file

@ -61,7 +61,7 @@ class RoomMemberListController @Inject constructor(
roomMemberSummaryFilter.filter = data.filter
val roomMembersByPowerLevel = data.roomMemberSummaries.invoke() ?: return
val threePidInvites = data.threePidInvites()
val filteredThreePidInvites = data.threePidInvites()
?.filter { event ->
event.content.toModel<RoomThirdPartyInviteContent>()
?.takeIf {
@ -69,7 +69,7 @@ class RoomMemberListController @Inject constructor(
} != null
}
.orEmpty()
var threePidInvitesDone = threePidInvites.isEmpty()
var threePidInvitesDone = filteredThreePidInvites.isEmpty()
for ((powerLevelCategory, roomMemberList) in roomMembersByPowerLevel) {
val filteredRoomMemberList = roomMemberList.filter { roomMemberSummaryFilter.test(it) }
@ -83,7 +83,7 @@ class RoomMemberListController @Inject constructor(
stringProvider.getString(RoomMemberListCategories.INVITE.titleRes)
)
buildThreePidInvites(data)
buildThreePidInvites(filteredThreePidInvites, data.actionsPermissions.canRevokeThreePidInvite)
threePidInvitesDone = true
}
@ -107,7 +107,7 @@ class RoomMemberListController @Inject constructor(
id("divider_threepidinvites")
}
buildThreePidInvites(data)
buildThreePidInvites(filteredThreePidInvites, data.actionsPermissions.canRevokeThreePidInvite)
threePidInvitesDone = true
}
}
@ -118,7 +118,7 @@ class RoomMemberListController @Inject constructor(
stringProvider.getString(RoomMemberListCategories.INVITE.titleRes)
)
buildThreePidInvites(data)
buildThreePidInvites(filteredThreePidInvites, data.actionsPermissions.canRevokeThreePidInvite)
}
}
@ -148,11 +148,10 @@ class RoomMemberListController @Inject constructor(
}
}
private fun buildThreePidInvites(data: RoomMemberListViewState) {
private fun buildThreePidInvites(filteredThreePidInvites: List<Event>, canRevokeThreePidInvite: Boolean) {
val host = this
data.threePidInvites()
?.filter { it.content.toModel<RoomThirdPartyInviteContent>() != null }
?.join(
filteredThreePidInvites
.join(
each = { idx, event ->
event.content.toModel<RoomThirdPartyInviteContent>()
?.let { content ->
@ -160,7 +159,7 @@ class RoomMemberListController @Inject constructor(
id("3pid_$idx")
matrixItem(MatrixItem.UserItem("@", displayName = content.displayName))
avatarRenderer(host.avatarRenderer)
editable(data.actionsPermissions.canRevokeThreePidInvite)
editable(canRevokeThreePidInvite)
clickListener {
host.callback?.onThreePidInviteClicked(event)
}