mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 16:10:20 +00:00
Fix various bugs in the moderation feature. (#2608)
* Fix search field string. * Show your own user as an Admin when changing roles. * Also show invited users when changing roles. * Don't allow admin's to kick/ban other admins or themselves. * Fix a bug when left members were counted as admins/moderators. * Show when a member is pending. * Add sections to the change role screen.
This commit is contained in:
@@ -23,11 +23,17 @@ struct RoomMemberDetails: Identifiable, Hashable {
|
||||
let avatarURL: URL?
|
||||
let permalink: URL?
|
||||
|
||||
var isInvited: Bool
|
||||
var isIgnored: Bool
|
||||
var isBanned: Bool
|
||||
|
||||
enum Role { case administrator, moderator, user }
|
||||
let role: Role
|
||||
|
||||
func matches(searchQuery: String) -> Bool {
|
||||
guard !searchQuery.isEmpty else { return true }
|
||||
return id.localizedStandardContains(searchQuery) || name?.localizedStandardContains(searchQuery) == true
|
||||
}
|
||||
}
|
||||
|
||||
extension RoomMemberDetails {
|
||||
@@ -37,6 +43,7 @@ extension RoomMemberDetails {
|
||||
avatarURL = proxy.avatarURL
|
||||
permalink = proxy.permalink
|
||||
|
||||
isInvited = proxy.membership == .invite
|
||||
isIgnored = proxy.isIgnored
|
||||
isBanned = proxy.membership == .ban
|
||||
role = .init(proxy.role)
|
||||
@@ -48,6 +55,7 @@ extension RoomMemberDetails {
|
||||
avatarURL = nil
|
||||
permalink = nil
|
||||
|
||||
isInvited = false
|
||||
isIgnored = false
|
||||
isBanned = false
|
||||
role = .user
|
||||
|
||||
@@ -31,6 +31,11 @@ protocol RoomMemberProxyProtocol: AnyObject {
|
||||
}
|
||||
|
||||
extension RoomMemberProxyProtocol {
|
||||
/// The member is active in the room (joined or invited).
|
||||
var isActive: Bool {
|
||||
membership == .join || membership == .invite
|
||||
}
|
||||
|
||||
var permalink: URL? {
|
||||
try? PermalinkBuilder.permalinkTo(userIdentifier: userID,
|
||||
baseURL: ServiceLocator.shared.settings.permalinkBaseURL)
|
||||
|
||||
Reference in New Issue
Block a user