mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 21:33:26 +00:00
49 lines
1.3 KiB
Swift
49 lines
1.3 KiB
Swift
//
|
|
// Copyright 2025 Element Creations Ltd.
|
|
// Copyright 2023-2025 New Vector Ltd.
|
|
//
|
|
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial.
|
|
// Please see LICENSE files in the repository root for full details.
|
|
//
|
|
|
|
import Foundation
|
|
import MatrixRustSDK
|
|
|
|
nonisolated struct RoomMemberDetails: Identifiable, Hashable {
|
|
let id: String
|
|
let name: String?
|
|
let avatarURL: URL?
|
|
let status: UserStatus
|
|
|
|
let permalink: URL?
|
|
|
|
var isInvited: Bool
|
|
var isIgnored: Bool
|
|
var isBanned: Bool
|
|
var isActive: Bool
|
|
|
|
let role: RoomRole
|
|
let powerLevel: RoomPowerLevel
|
|
|
|
func matches(searchQuery: String) -> Bool {
|
|
guard !searchQuery.isEmpty else { return true }
|
|
return id.localizedStandardContains(searchQuery) || name?.localizedStandardContains(searchQuery) == true
|
|
}
|
|
}
|
|
|
|
nonisolated extension RoomMemberDetails {
|
|
init(withProxy proxy: RoomMemberProxyProtocol) {
|
|
id = proxy.userID
|
|
name = proxy.displayName
|
|
avatarURL = proxy.avatarURL
|
|
status = proxy.status
|
|
permalink = proxy.permalink
|
|
isActive = proxy.isActive
|
|
isInvited = proxy.membership == .invite
|
|
isIgnored = proxy.isIgnored
|
|
isBanned = proxy.membership == .ban
|
|
role = proxy.role
|
|
powerLevel = proxy.powerLevel
|
|
}
|
|
}
|