mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 06:55:59 +00:00
Rename UserProfileProxy to UserProfile. It's a pure struct and proxies nothing.
Also remove the redundant `userID` property given `id` already exists (for Identifiable conformance).
This commit is contained in:
@@ -786,7 +786,7 @@ class ClientProxy: ClientProxyProtocol {
|
||||
}
|
||||
}
|
||||
|
||||
func profile(for userID: String) async -> Result<UserProfileProxy, ClientProxyError> {
|
||||
func profile(for userID: String) async -> Result<UserProfile, ClientProxyError> {
|
||||
do {
|
||||
return try await .success(.init(sdkUserProfile: client.getProfile(userId: userID)))
|
||||
} catch {
|
||||
@@ -933,14 +933,14 @@ class ClientProxy: ClientProxyProtocol {
|
||||
return rooms
|
||||
}
|
||||
|
||||
func recentConversationCounterparts() async -> [UserProfileProxy] {
|
||||
func recentConversationCounterparts() async -> [UserProfile] {
|
||||
let maxResultsToReturn = 5
|
||||
|
||||
guard case let .success(roomIdentifiers) = await recentlyVisitedRoomIDs() else {
|
||||
return []
|
||||
}
|
||||
|
||||
var users: OrderedSet<UserProfileProxy> = []
|
||||
var users: OrderedSet<UserProfile> = []
|
||||
|
||||
for roomID in roomIdentifiers {
|
||||
guard case let .joined(roomProxy) = await roomForIdentifier(roomID),
|
||||
|
||||
@@ -232,7 +232,7 @@ protocol ClientProxyProtocol: AnyObject {
|
||||
|
||||
func searchUsers(searchTerm: String, limit: UInt) async -> Result<SearchUsersResultsProxy, ClientProxyError>
|
||||
|
||||
func profile(for userID: String) async -> Result<UserProfileProxy, ClientProxyError>
|
||||
func profile(for userID: String) async -> Result<UserProfile, ClientProxyError>
|
||||
|
||||
func roomDirectorySearchProxy() -> RoomDirectorySearchProxyProtocol
|
||||
|
||||
@@ -261,7 +261,7 @@ protocol ClientProxyProtocol: AnyObject {
|
||||
func trackRecentlyVisitedRoom(_ roomID: String) async -> Result<Void, ClientProxyError>
|
||||
|
||||
func recentlyVisitedRooms(filter: @Sendable (JoinedRoomProxyProtocol) -> Bool) async -> [JoinedRoomProxyProtocol]
|
||||
func recentConversationCounterparts() async -> [UserProfileProxy]
|
||||
func recentConversationCounterparts() async -> [UserProfile]
|
||||
|
||||
// MARK: - Crypto
|
||||
|
||||
|
||||
@@ -78,7 +78,7 @@ extension BaseRoomInfoProxyProtocol {
|
||||
}
|
||||
|
||||
if isDirect, avatarURL == nil, heroes.count == 1 {
|
||||
return .heroes(heroes.map(UserProfileProxy.init))
|
||||
return .heroes(heroes.map(UserProfile.init))
|
||||
}
|
||||
|
||||
return .room(id: id, name: displayName, avatarURL: avatarURL)
|
||||
|
||||
@@ -43,7 +43,7 @@ nonisolated struct RoomSummary {
|
||||
let isSpace: Bool
|
||||
let avatarURL: URL?
|
||||
|
||||
let heroes: [UserProfileProxy]
|
||||
let heroes: [UserProfile]
|
||||
let activeMembersCount: UInt
|
||||
|
||||
let lastMessage: AttributedString?
|
||||
|
||||
@@ -354,7 +354,7 @@ class RoomSummaryProvider: RoomSummaryProviderProtocol {
|
||||
isDirect: roomInfo.isDirect,
|
||||
isSpace: roomInfo.isSpace,
|
||||
avatarURL: roomInfo.avatarUrl.flatMap(URL.init(string:)),
|
||||
heroes: roomInfo.heroes.map(UserProfileProxy.init),
|
||||
heroes: roomInfo.heroes.map(UserProfile.init),
|
||||
activeMembersCount: UInt(roomInfo.activeMembersCount),
|
||||
lastMessage: attributedLastMessage,
|
||||
lastMessageDate: lastMessageDate,
|
||||
|
||||
@@ -9,7 +9,7 @@ import Foundation
|
||||
|
||||
struct UserToInvite: Identifiable {
|
||||
/// The profile of the user being invited.
|
||||
var user: UserProfileProxy
|
||||
var user: UserProfile
|
||||
|
||||
/// The ID of the user being invited.
|
||||
var id: String {
|
||||
|
||||
+2
-2
@@ -89,7 +89,7 @@ class SessionVerificationControllerProxy: SessionVerificationControllerProxyProt
|
||||
MXLog.info("Acknowledging verification request")
|
||||
|
||||
do {
|
||||
try await sessionVerificationController.acknowledgeVerificationRequest(senderId: details.senderProfile.userID, flowId: details.flowID)
|
||||
try await sessionVerificationController.acknowledgeVerificationRequest(senderId: details.senderProfile.id, flowId: details.flowID)
|
||||
return .success(())
|
||||
} catch {
|
||||
MXLog.error("Failed requesting session verification with error: \(error)")
|
||||
@@ -190,7 +190,7 @@ class SessionVerificationControllerProxy: SessionVerificationControllerProxyProt
|
||||
fileprivate func didReceiveVerificationRequest(details: MatrixRustSDK.SessionVerificationRequestDetails) {
|
||||
MXLog.info("Received verification request \(details)")
|
||||
|
||||
let details = SessionVerificationRequestDetails(senderProfile: UserProfileProxy(sdkUserProfile: details.senderProfile),
|
||||
let details = SessionVerificationRequestDetails(senderProfile: UserProfile(sdkUserProfile: details.senderProfile),
|
||||
flowID: details.flowId,
|
||||
deviceID: details.deviceId,
|
||||
deviceDisplayName: details.deviceDisplayName,
|
||||
|
||||
+1
-1
@@ -31,7 +31,7 @@ enum SessionVerificationControllerProxyAction: Equatable {
|
||||
}
|
||||
|
||||
struct SessionVerificationRequestDetails: Equatable {
|
||||
let senderProfile: UserProfileProxy
|
||||
let senderProfile: UserProfile
|
||||
let flowID: String
|
||||
let deviceID: String
|
||||
let deviceDisplayName: String?
|
||||
|
||||
@@ -28,7 +28,7 @@ struct SpaceServiceRoom {
|
||||
var childrenCount: Int
|
||||
|
||||
var joinedMembersCount: Int
|
||||
var heroes: [UserProfileProxy]
|
||||
var heroes: [UserProfile]
|
||||
var topic: String?
|
||||
var canonicalAlias: String?
|
||||
|
||||
@@ -75,7 +75,7 @@ extension SpaceServiceRoom {
|
||||
childrenCount = Int(spaceRoom.childrenCount)
|
||||
|
||||
joinedMembersCount = Int(spaceRoom.numJoinedMembers)
|
||||
heroes = (spaceRoom.heroes ?? []).map(UserProfileProxy.init)
|
||||
heroes = (spaceRoom.heroes ?? []).map(UserProfile.init)
|
||||
topic = spaceRoom.topic
|
||||
canonicalAlias = spaceRoom.canonicalAlias
|
||||
|
||||
@@ -97,7 +97,7 @@ extension SpaceServiceRoom {
|
||||
isDM: Bool? = nil,
|
||||
childrenCount: Int = 0,
|
||||
joinedMembersCount: Int = 0,
|
||||
heroes: [UserProfileProxy] = [],
|
||||
heroes: [UserProfile] = [],
|
||||
topic: String? = nil,
|
||||
canonicalAlias: String? = nil,
|
||||
joinRule: JoinRule? = nil,
|
||||
|
||||
@@ -10,7 +10,7 @@ import Foundation
|
||||
|
||||
struct UserDiscoverySection {
|
||||
let type: UserDiscoverySectionType
|
||||
let users: [UserProfileProxy]
|
||||
let users: [UserProfile]
|
||||
|
||||
var title: String? {
|
||||
switch type {
|
||||
|
||||
@@ -15,7 +15,7 @@ final class UserDiscoveryService: UserDiscoveryServiceProtocol {
|
||||
self.clientProxy = clientProxy
|
||||
}
|
||||
|
||||
func searchProfiles(with searchQuery: String) async -> Result<[UserProfileProxy], UserDiscoveryErrorType> {
|
||||
func searchProfiles(with searchQuery: String) async -> Result<[UserProfile], UserDiscoveryErrorType> {
|
||||
async let queriedProfile = profileIfPossible(with: searchQuery)
|
||||
|
||||
do {
|
||||
@@ -32,7 +32,7 @@ final class UserDiscoveryService: UserDiscoveryServiceProtocol {
|
||||
}
|
||||
}
|
||||
|
||||
private func merge(queriedProfile: UserProfileProxy?, searchResults: SearchUsersResultsProxy) -> [UserProfileProxy] {
|
||||
private func merge(queriedProfile: UserProfile?, searchResults: SearchUsersResultsProxy) -> [UserProfile] {
|
||||
let searchResults = searchResults.results
|
||||
|
||||
guard let queriedProfile else {
|
||||
@@ -40,13 +40,13 @@ final class UserDiscoveryService: UserDiscoveryServiceProtocol {
|
||||
}
|
||||
|
||||
let filteredSearchResult = searchResults.filter {
|
||||
$0.userID != queriedProfile.userID
|
||||
$0.id != queriedProfile.id
|
||||
}
|
||||
|
||||
return [queriedProfile] + filteredSearchResult
|
||||
}
|
||||
|
||||
private func profileIfPossible(with searchQuery: String) async -> UserProfileProxy? {
|
||||
private func profileIfPossible(with searchQuery: String) async -> UserProfile? {
|
||||
guard searchQuery.isMatrixIdentifier, searchQuery != clientProxy.userID else {
|
||||
return nil
|
||||
}
|
||||
@@ -57,9 +57,9 @@ final class UserDiscoveryService: UserDiscoveryServiceProtocol {
|
||||
return getProfileResult ?? .init(userID: searchQuery)
|
||||
}
|
||||
|
||||
private func filterAccountOwner(_ profiles: [UserProfileProxy]) -> [UserProfileProxy] {
|
||||
private func filterAccountOwner(_ profiles: [UserProfile]) -> [UserProfile] {
|
||||
let accountOwnerID = clientProxy.userID
|
||||
return profiles.filter { $0.userID != accountOwnerID }
|
||||
return profiles.filter { $0.id != accountOwnerID }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -14,5 +14,5 @@ enum UserDiscoveryErrorType: Error {
|
||||
|
||||
// sourcery: AutoMockable
|
||||
protocol UserDiscoveryServiceProtocol {
|
||||
func searchProfiles(with searchQuery: String) async -> Result<[UserProfileProxy], UserDiscoveryErrorType>
|
||||
func searchProfiles(with searchQuery: String) async -> Result<[UserProfile], UserDiscoveryErrorType>
|
||||
}
|
||||
|
||||
+9
-15
@@ -9,37 +9,37 @@
|
||||
import Foundation
|
||||
import MatrixRustSDK
|
||||
|
||||
nonisolated struct UserProfileProxy: Equatable, Hashable {
|
||||
let userID: String
|
||||
nonisolated struct UserProfile: Hashable, Identifiable {
|
||||
let id: String
|
||||
let displayName: String?
|
||||
let avatarURL: URL?
|
||||
|
||||
init(userID: String, displayName: String? = nil, avatarURL: URL? = nil) {
|
||||
self.userID = userID
|
||||
id = userID
|
||||
self.displayName = displayName
|
||||
self.avatarURL = avatarURL
|
||||
}
|
||||
|
||||
init(member: RoomMemberDetails) {
|
||||
userID = member.id
|
||||
id = member.id
|
||||
displayName = member.isBanned ? nil : member.name
|
||||
avatarURL = member.isBanned ? nil : member.avatarURL
|
||||
}
|
||||
|
||||
init(sender: TimelineItemSender) {
|
||||
userID = sender.id
|
||||
id = sender.id
|
||||
displayName = sender.displayName
|
||||
avatarURL = sender.avatarURL
|
||||
}
|
||||
|
||||
init(sdkUserProfile: MatrixRustSDK.UserProfile) {
|
||||
userID = sdkUserProfile.userId
|
||||
id = sdkUserProfile.userId
|
||||
displayName = sdkUserProfile.displayName
|
||||
avatarURL = sdkUserProfile.avatarUrl.flatMap(URL.init(string:))
|
||||
}
|
||||
|
||||
init(sdkRoomHero: MatrixRustSDK.RoomHero) {
|
||||
userID = sdkRoomHero.userId
|
||||
id = sdkRoomHero.userId
|
||||
displayName = sdkRoomHero.displayName
|
||||
avatarURL = sdkRoomHero.avatarUrl.flatMap(URL.init(string:))
|
||||
}
|
||||
@@ -56,19 +56,13 @@ nonisolated struct UserProfileProxy: Equatable, Hashable {
|
||||
}
|
||||
|
||||
struct SearchUsersResultsProxy {
|
||||
let results: [UserProfileProxy]
|
||||
let results: [UserProfile]
|
||||
let limited: Bool
|
||||
}
|
||||
|
||||
extension SearchUsersResultsProxy {
|
||||
init(sdkResults: MatrixRustSDK.SearchUsersResults) {
|
||||
results = sdkResults.results.map(UserProfileProxy.init)
|
||||
results = sdkResults.results.map(UserProfile.init)
|
||||
limited = sdkResults.limited
|
||||
}
|
||||
}
|
||||
|
||||
extension UserProfileProxy: Identifiable {
|
||||
var id: String {
|
||||
userID
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user