* always open manage member sheet * Update ElementX/Sources/Screens/ManageRoomMemberSheet/ManageRoomMemberSheetModels.swift Co-authored-by: Doug <6060466+pixlwave@users.noreply.github.com> * Update ElementX/Sources/Screens/ManageRoomMemberSheet/ManageRoomMemberSheetModels.swift Co-authored-by: Doug <6060466+pixlwave@users.noreply.github.com> * pr suggestions and handled the buttons actions correctly * Update ElementX/Sources/Screens/ManageRoomMemberSheet/View/ManageRoomMemberSheetView.swift Co-authored-by: Doug <6060466+pixlwave@users.noreply.github.com> * fixed some compilation errors * added some documentation * using a struct instead of a protocol * using arguments instead of a struct --------- Co-authored-by: Doug <6060466+pixlwave@users.noreply.github.com>
68 lines
1.9 KiB
Swift
68 lines
1.9 KiB
Swift
//
|
|
// Copyright 2023, 2024 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
|
|
|
|
struct UserProfileProxy: Equatable, Hashable {
|
|
let userID: String
|
|
let displayName: String?
|
|
let avatarURL: URL?
|
|
|
|
init(userID: String, displayName: String? = nil, avatarURL: URL? = nil) {
|
|
self.userID = userID
|
|
self.displayName = displayName
|
|
self.avatarURL = avatarURL
|
|
}
|
|
|
|
init(member: RoomMemberDetails) {
|
|
userID = member.id
|
|
displayName = member.isBanned ? nil : member.name
|
|
avatarURL = member.isBanned ? nil : member.avatarURL
|
|
}
|
|
|
|
init(sender: TimelineItemSender) {
|
|
userID = sender.id
|
|
displayName = sender.displayName
|
|
avatarURL = sender.avatarURL
|
|
}
|
|
|
|
init(sdkUserProfile: MatrixRustSDK.UserProfile) {
|
|
userID = sdkUserProfile.userId
|
|
displayName = sdkUserProfile.displayName
|
|
avatarURL = sdkUserProfile.avatarUrl.flatMap(URL.init(string:))
|
|
}
|
|
|
|
init(sdkRoomHero: MatrixRustSDK.RoomHero) {
|
|
userID = sdkRoomHero.userId
|
|
displayName = sdkRoomHero.displayName
|
|
avatarURL = sdkRoomHero.avatarUrl.flatMap(URL.init(string:))
|
|
}
|
|
|
|
/// A user is meant to be "verified" when the GET profile returns back either the display name or the avatar
|
|
/// If isn't we aren't sure that the related matrix id really exists.
|
|
var isVerified: Bool {
|
|
displayName != nil || avatarURL != nil
|
|
}
|
|
}
|
|
|
|
struct SearchUsersResultsProxy {
|
|
let results: [UserProfileProxy]
|
|
let limited: Bool
|
|
}
|
|
|
|
extension SearchUsersResultsProxy {
|
|
init(sdkResults: MatrixRustSDK.SearchUsersResults) {
|
|
results = sdkResults.results.map(UserProfileProxy.init)
|
|
limited = sdkResults.limited
|
|
}
|
|
}
|
|
|
|
extension UserProfileProxy: Identifiable {
|
|
var id: String { userID }
|
|
}
|