mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 16:10:20 +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:
@@ -64,7 +64,7 @@ enum InviteUsersFlow: Hashable {
|
||||
/// Invite people into the current room.
|
||||
case existingRoom
|
||||
/// Start a new room with the given invitee pre-selected and mandatory.
|
||||
case newRoom(mandatoryInvitee: UserProfileProxy)
|
||||
case newRoom(mandatoryInvitee: UserProfile)
|
||||
}
|
||||
|
||||
// swiftlint:disable:next type_body_length
|
||||
|
||||
@@ -405,7 +405,7 @@ class UserSessionFlowCoordinator: FlowCoordinatorProtocol {
|
||||
|
||||
MXLog.info("Received session verification request")
|
||||
|
||||
if details.senderProfile.userID == userSession.clientProxy.userID {
|
||||
if details.senderProfile.id == userSession.clientProxy.userID {
|
||||
presentSessionVerificationScreen(flow: .deviceResponder(requestDetails: details))
|
||||
} else {
|
||||
presentSessionVerificationScreen(flow: .userResponder(requestDetails: details))
|
||||
|
||||
@@ -3533,14 +3533,14 @@ nonisolated class ClientProxyMock: ClientProxyProtocol, @unchecked Sendable {
|
||||
}
|
||||
|
||||
private let profileForReturnValueLock = NSLock()
|
||||
private nonisolated(unsafe) var profileForUnderlyingReturnValue: Result<UserProfileProxy, ClientProxyError>!
|
||||
var profileForReturnValue: Result<UserProfileProxy, ClientProxyError>! {
|
||||
private nonisolated(unsafe) var profileForUnderlyingReturnValue: Result<UserProfile, ClientProxyError>!
|
||||
var profileForReturnValue: Result<UserProfile, ClientProxyError>! {
|
||||
get { profileForReturnValueLock.withLock { profileForUnderlyingReturnValue } }
|
||||
set { profileForReturnValueLock.withLock { profileForUnderlyingReturnValue = newValue } }
|
||||
}
|
||||
nonisolated(unsafe) var profileForClosure: ((String) async -> Result<UserProfileProxy, ClientProxyError>)?
|
||||
nonisolated(unsafe) var profileForClosure: ((String) async -> Result<UserProfile, ClientProxyError>)?
|
||||
|
||||
@concurrent func profile(for userID: String) async -> Result<UserProfileProxy, ClientProxyError> {
|
||||
@concurrent func profile(for userID: String) async -> Result<UserProfile, ClientProxyError> {
|
||||
profileForCallsCountLock.withLock { profileForUnderlyingCallsCount += 1 }
|
||||
profileForReceivedUserID = userID
|
||||
profileForReceivedInvocationsLock.withLock { profileForUnderlyingReceivedInvocations.append(userID) }
|
||||
@@ -3972,14 +3972,14 @@ nonisolated class ClientProxyMock: ClientProxyProtocol, @unchecked Sendable {
|
||||
}
|
||||
|
||||
private let recentConversationCounterpartsReturnValueLock = NSLock()
|
||||
private nonisolated(unsafe) var recentConversationCounterpartsUnderlyingReturnValue: [UserProfileProxy]!
|
||||
var recentConversationCounterpartsReturnValue: [UserProfileProxy]! {
|
||||
private nonisolated(unsafe) var recentConversationCounterpartsUnderlyingReturnValue: [UserProfile]!
|
||||
var recentConversationCounterpartsReturnValue: [UserProfile]! {
|
||||
get { recentConversationCounterpartsReturnValueLock.withLock { recentConversationCounterpartsUnderlyingReturnValue } }
|
||||
set { recentConversationCounterpartsReturnValueLock.withLock { recentConversationCounterpartsUnderlyingReturnValue = newValue } }
|
||||
}
|
||||
nonisolated(unsafe) var recentConversationCounterpartsClosure: (() async -> [UserProfileProxy])?
|
||||
nonisolated(unsafe) var recentConversationCounterpartsClosure: (() async -> [UserProfile])?
|
||||
|
||||
@concurrent func recentConversationCounterparts() async -> [UserProfileProxy] {
|
||||
@concurrent func recentConversationCounterparts() async -> [UserProfile] {
|
||||
recentConversationCounterpartsCallsCountLock.withLock { recentConversationCounterpartsUnderlyingCallsCount += 1 }
|
||||
if let recentConversationCounterpartsClosure = recentConversationCounterpartsClosure {
|
||||
return await recentConversationCounterpartsClosure()
|
||||
@@ -14057,14 +14057,14 @@ nonisolated class UserDiscoveryServiceMock: UserDiscoveryServiceProtocol, @unche
|
||||
}
|
||||
|
||||
private let searchProfilesWithReturnValueLock = NSLock()
|
||||
private nonisolated(unsafe) var searchProfilesWithUnderlyingReturnValue: Result<[UserProfileProxy], UserDiscoveryErrorType>!
|
||||
var searchProfilesWithReturnValue: Result<[UserProfileProxy], UserDiscoveryErrorType>! {
|
||||
private nonisolated(unsafe) var searchProfilesWithUnderlyingReturnValue: Result<[UserProfile], UserDiscoveryErrorType>!
|
||||
var searchProfilesWithReturnValue: Result<[UserProfile], UserDiscoveryErrorType>! {
|
||||
get { searchProfilesWithReturnValueLock.withLock { searchProfilesWithUnderlyingReturnValue } }
|
||||
set { searchProfilesWithReturnValueLock.withLock { searchProfilesWithUnderlyingReturnValue = newValue } }
|
||||
}
|
||||
nonisolated(unsafe) var searchProfilesWithClosure: ((String) async -> Result<[UserProfileProxy], UserDiscoveryErrorType>)?
|
||||
nonisolated(unsafe) var searchProfilesWithClosure: ((String) async -> Result<[UserProfile], UserDiscoveryErrorType>)?
|
||||
|
||||
@concurrent func searchProfiles(with searchQuery: String) async -> Result<[UserProfileProxy], UserDiscoveryErrorType> {
|
||||
@concurrent func searchProfiles(with searchQuery: String) async -> Result<[UserProfile], UserDiscoveryErrorType> {
|
||||
searchProfilesWithCallsCountLock.withLock { searchProfilesWithUnderlyingCallsCount += 1 }
|
||||
searchProfilesWithReceivedSearchQuery = searchQuery
|
||||
searchProfilesWithReceivedInvocationsLock.withLock { searchProfilesWithUnderlyingReceivedInvocations.append(searchQuery) }
|
||||
|
||||
@@ -8,29 +8,29 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
extension UserProfileProxy {
|
||||
extension UserProfile {
|
||||
/// Mocks
|
||||
static var mockAlice: UserProfileProxy {
|
||||
static var mockAlice: UserProfile {
|
||||
.init(userID: "@alice:matrix.org", displayName: "Alice", avatarURL: "mxc://matrix.org/UcCimidcvpFvWkPzvjXMQPHA")
|
||||
}
|
||||
|
||||
static var mockBob: UserProfileProxy {
|
||||
static var mockBob: UserProfile {
|
||||
.init(userID: "@bob:matrix.org", displayName: "Bob", avatarURL: nil)
|
||||
}
|
||||
|
||||
static var mockBobby: UserProfileProxy {
|
||||
static var mockBobby: UserProfile {
|
||||
.init(userID: "@bobby:matrix.org", displayName: "Bobby", avatarURL: nil)
|
||||
}
|
||||
|
||||
static var mockCharlie: UserProfileProxy {
|
||||
static var mockCharlie: UserProfile {
|
||||
.init(userID: "@charlie:matrix.org", displayName: "Charlie", avatarURL: nil)
|
||||
}
|
||||
|
||||
static var mockDan: UserProfileProxy {
|
||||
static var mockDan: UserProfile {
|
||||
.init(userID: "@dan:matrix.org", displayName: "Dan", avatarURL: .mockMXCUserAvatar)
|
||||
}
|
||||
|
||||
static var mockVerbose: UserProfileProxy {
|
||||
static var mockVerbose: UserProfile {
|
||||
.init(userID: "@charlie:matrix.org", displayName: "Charlie is the best display name", avatarURL: nil)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ import SwiftUI
|
||||
struct AvatarHeaderView<Footer: View>: View {
|
||||
private enum AvatarInfo {
|
||||
case room(RoomAvatar)
|
||||
case user(UserProfileProxy)
|
||||
case user(UserProfile)
|
||||
}
|
||||
|
||||
private enum Badge: Hashable {
|
||||
@@ -44,7 +44,7 @@ struct AvatarHeaderView<Footer: View>: View {
|
||||
if let roomAlias = room.canonicalAlias {
|
||||
subtitle = roomAlias
|
||||
} else if room.isDirect, case let .heroes(heroes) = room.avatar, heroes.count == 1 {
|
||||
subtitle = heroes[0].userID
|
||||
subtitle = heroes[0].id
|
||||
} else {
|
||||
subtitle = nil
|
||||
}
|
||||
@@ -70,10 +70,10 @@ struct AvatarHeaderView<Footer: View>: View {
|
||||
mediaProvider: MediaProviderProtocol? = nil,
|
||||
onAvatarTap: ((URL) -> Void)? = nil,
|
||||
@ViewBuilder footer: @escaping () -> Footer) {
|
||||
let dmRecipientProfile = UserProfileProxy(member: dmRecipient)
|
||||
avatarInfo = .room(.heroes([dmRecipientProfile, UserProfileProxy(member: accountOwner)]))
|
||||
title = dmRecipientProfile.displayName ?? dmRecipientProfile.userID
|
||||
subtitle = dmRecipientProfile.displayName == nil ? nil : dmRecipientProfile.userID
|
||||
let dmRecipientProfile = UserProfile(member: dmRecipient)
|
||||
avatarInfo = .room(.heroes([dmRecipientProfile, UserProfile(member: accountOwner)]))
|
||||
title = dmRecipientProfile.displayName ?? dmRecipientProfile.id
|
||||
subtitle = dmRecipientProfile.displayName == nil ? nil : dmRecipientProfile.id
|
||||
|
||||
avatarSize = .user(on: .dmDetails)
|
||||
self.mediaProvider = mediaProvider
|
||||
@@ -89,7 +89,7 @@ struct AvatarHeaderView<Footer: View>: View {
|
||||
mediaProvider: MediaProviderProtocol? = nil,
|
||||
onAvatarTap: ((URL) -> Void)? = nil,
|
||||
@ViewBuilder footer: @escaping () -> Footer) {
|
||||
let profile = UserProfileProxy(member: member)
|
||||
let profile = UserProfile(member: member)
|
||||
|
||||
self.init(user: profile,
|
||||
isVerified: isVerified,
|
||||
@@ -99,15 +99,15 @@ struct AvatarHeaderView<Footer: View>: View {
|
||||
footer: footer)
|
||||
}
|
||||
|
||||
init(user: UserProfileProxy,
|
||||
init(user: UserProfile,
|
||||
isVerified: Bool,
|
||||
avatarSize: Avatars.Size,
|
||||
mediaProvider: MediaProviderProtocol? = nil,
|
||||
onAvatarTap: ((URL) -> Void)? = nil,
|
||||
@ViewBuilder footer: @escaping () -> Footer) {
|
||||
avatarInfo = .user(user)
|
||||
title = user.displayName ?? user.userID
|
||||
subtitle = user.displayName == nil ? nil : user.userID
|
||||
title = user.displayName ?? user.id
|
||||
subtitle = user.displayName == nil ? nil : user.id
|
||||
|
||||
self.avatarSize = avatarSize
|
||||
self.mediaProvider = mediaProvider
|
||||
@@ -123,7 +123,7 @@ struct AvatarHeaderView<Footer: View>: View {
|
||||
mediaProvider: MediaProviderProtocol? = nil,
|
||||
onAvatarTap: ((URL) -> Void)? = nil,
|
||||
@ViewBuilder footer: @escaping () -> Footer) {
|
||||
let profile = UserProfileProxy(sender: sender)
|
||||
let profile = UserProfile(sender: sender)
|
||||
|
||||
self.init(user: profile,
|
||||
isVerified: false,
|
||||
@@ -180,8 +180,8 @@ struct AvatarHeaderView<Footer: View>: View {
|
||||
switch avatarInfo {
|
||||
case .room(let roomAvatar):
|
||||
return roomAvatar.hasURL ? L10n.a11yViewAvatar : L10n.a11yAvatar
|
||||
case .user(let userProfileProxy):
|
||||
return userProfileProxy.avatarURL != nil ? L10n.a11yViewAvatar : L10n.a11yAvatar
|
||||
case .user(let userProfile):
|
||||
return userProfile.avatarURL != nil ? L10n.a11yViewAvatar : L10n.a11yAvatar
|
||||
}
|
||||
}
|
||||
|
||||
@@ -198,7 +198,7 @@ struct AvatarHeaderView<Footer: View>: View {
|
||||
case .user(let userProfile):
|
||||
LoadableAvatarImage(url: userProfile.avatarURL,
|
||||
name: userProfile.displayName,
|
||||
contentID: userProfile.userID,
|
||||
contentID: userProfile.id,
|
||||
avatarSize: avatarSize,
|
||||
mediaProvider: mediaProvider,
|
||||
onTap: onAvatarTap)
|
||||
|
||||
@@ -10,7 +10,7 @@ import Compound
|
||||
import SwiftUI
|
||||
|
||||
struct JoinedMembersBadgeView: View {
|
||||
let heroes: [UserProfileProxy]
|
||||
let heroes: [UserProfile]
|
||||
var shouldHideAvatars = false
|
||||
let joinedCount: Int
|
||||
|
||||
@@ -46,7 +46,7 @@ struct JoinedMembersBadgeView: View {
|
||||
ForEach(heroes.prefix(3).reversed()) { hero in
|
||||
LoadableAvatarImage(url: shouldHideAvatars ? nil : hero.avatarURL,
|
||||
name: hero.displayName,
|
||||
contentID: hero.userID,
|
||||
contentID: hero.id,
|
||||
avatarSize: .user(on: .spaceHeader),
|
||||
mediaProvider: mediaProvider)
|
||||
.mask {
|
||||
|
||||
@@ -69,7 +69,7 @@ struct LocationMarkerView: View {
|
||||
if let userProfile = kind.userProfile {
|
||||
LoadableAvatarImage(url: userProfile.avatarURL,
|
||||
name: userProfile.displayName,
|
||||
contentID: userProfile.userID,
|
||||
contentID: userProfile.id,
|
||||
avatarSize: .user(on: .map),
|
||||
mediaProvider: mediaProvider)
|
||||
.overlay {
|
||||
|
||||
@@ -13,7 +13,7 @@ enum RoomAvatar: Equatable {
|
||||
/// An avatar generated from a Room's details.
|
||||
case room(id: String, name: String?, avatarURL: URL?)
|
||||
/// An avatar generated from a collection of room heroes.
|
||||
case heroes([UserProfileProxy])
|
||||
case heroes([UserProfile])
|
||||
/// An avatar generated from a Space's details.
|
||||
case space(id: String, name: String?, avatarURL: URL?)
|
||||
/// A static avatar for a tombstoned room.
|
||||
@@ -24,7 +24,7 @@ enum RoomAvatar: Equatable {
|
||||
case let .room(id, name, _):
|
||||
.room(id: id, name: name, avatarURL: nil)
|
||||
case let .heroes(users):
|
||||
.heroes(users.map { .init(userID: $0.userID, displayName: $0.displayName, avatarURL: nil) })
|
||||
.heroes(users.map { .init(userID: $0.id, displayName: $0.displayName, avatarURL: nil) })
|
||||
case .space(let id, let name, _):
|
||||
.space(id: id, name: name, avatarURL: nil)
|
||||
case .tombstoned:
|
||||
@@ -76,7 +76,7 @@ struct RoomAvatarImage: View {
|
||||
ZStack {
|
||||
LoadableAvatarImage(url: users[0].avatarURL,
|
||||
name: users[0].displayName,
|
||||
contentID: users[0].userID,
|
||||
contentID: users[0].id,
|
||||
avatarSize: avatarSize,
|
||||
mediaProvider: mediaProvider,
|
||||
onTap: onAvatarTap)
|
||||
@@ -84,7 +84,7 @@ struct RoomAvatarImage: View {
|
||||
|
||||
LoadableAvatarImage(url: users[1].avatarURL,
|
||||
name: users[1].displayName,
|
||||
contentID: users[1].userID,
|
||||
contentID: users[1].id,
|
||||
avatarSize: avatarSize,
|
||||
mediaProvider: mediaProvider,
|
||||
onTap: onAvatarTap)
|
||||
@@ -107,7 +107,7 @@ struct RoomAvatarImage: View {
|
||||
} else {
|
||||
LoadableAvatarImage(url: users[0].avatarURL,
|
||||
name: users[0].displayName,
|
||||
contentID: users[0].userID,
|
||||
contentID: users[0].id,
|
||||
avatarSize: avatarSize,
|
||||
mediaProvider: mediaProvider,
|
||||
onTap: onAvatarTap)
|
||||
|
||||
@@ -11,7 +11,7 @@ import MatrixRustSDK
|
||||
import SwiftUI
|
||||
|
||||
struct UserProfileListRow: View {
|
||||
let user: UserProfileProxy
|
||||
let user: UserProfile
|
||||
let membership: MembershipState?
|
||||
let mediaProvider: MediaProviderProtocol?
|
||||
|
||||
@@ -27,14 +27,14 @@ struct UserProfileListRow: View {
|
||||
if let membershipText = membership?.localizedDescription {
|
||||
return membershipText
|
||||
} else if user.displayName != nil {
|
||||
return user.userID
|
||||
return user.id
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
ListRow(label: .avatar(title: user.displayName ?? user.userID,
|
||||
ListRow(label: .avatar(title: user.displayName ?? user.id,
|
||||
description: subtitle,
|
||||
icon: avatar,
|
||||
role: isUnknownProfile ? .error : nil),
|
||||
@@ -44,7 +44,7 @@ struct UserProfileListRow: View {
|
||||
var avatar: LoadableAvatarImage {
|
||||
LoadableAvatarImage(url: user.avatarURL,
|
||||
name: user.displayName,
|
||||
contentID: user.userID,
|
||||
contentID: user.id,
|
||||
avatarSize: .user(on: .startChat),
|
||||
mediaProvider: mediaProvider)
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
import Foundation
|
||||
|
||||
struct BlockedUsersScreenViewState: BindableState {
|
||||
var blockedUsers: [UserProfileProxy]
|
||||
var blockedUsers: [UserProfile]
|
||||
var processingUserID: String?
|
||||
|
||||
var bindings = BlockedUsersScreenViewStateBindings()
|
||||
@@ -20,7 +20,7 @@ struct BlockedUsersScreenViewStateBindings {
|
||||
}
|
||||
|
||||
enum BlockedUsersScreenViewAction {
|
||||
case unblockUser(UserProfileProxy)
|
||||
case unblockUser(UserProfile)
|
||||
}
|
||||
|
||||
enum BlockedUsersScreenViewStateAlertType: Hashable {
|
||||
|
||||
@@ -23,7 +23,7 @@ class BlockedUsersScreenViewModel: BlockedUsersScreenViewModelType, BlockedUsers
|
||||
clientProxy = userSession.clientProxy
|
||||
self.userIndicatorController = userIndicatorController
|
||||
|
||||
let ignoredUsers = clientProxy.ignoredUsersPublisher.value?.map { UserProfileProxy(userID: $0) }
|
||||
let ignoredUsers = clientProxy.ignoredUsersPublisher.value?.map { UserProfile(userID: $0) }
|
||||
|
||||
super.init(initialViewState: BlockedUsersScreenViewState(blockedUsers: ignoredUsers ?? []),
|
||||
mediaProvider: userSession.mediaProvider)
|
||||
@@ -64,16 +64,16 @@ class BlockedUsersScreenViewModel: BlockedUsersScreenViewModelType, BlockedUsers
|
||||
defer { hideLoadingIndicator() }
|
||||
|
||||
if hideProfiles {
|
||||
state.blockedUsers = blockedUsers.map { UserProfileProxy(userID: $0) }
|
||||
state.blockedUsers = blockedUsers.map { UserProfile(userID: $0) }
|
||||
} else {
|
||||
state.blockedUsers = await withTaskGroup(of: UserProfileProxy.self) { group in
|
||||
state.blockedUsers = await withTaskGroup(of: UserProfile.self) { group in
|
||||
for userID in blockedUsers {
|
||||
group.addTask {
|
||||
await self.profile(for: userID)
|
||||
}
|
||||
}
|
||||
|
||||
var profiles = [UserProfileProxy]()
|
||||
var profiles = [UserProfile]()
|
||||
for await profile in group {
|
||||
profiles.append(profile)
|
||||
}
|
||||
@@ -84,19 +84,19 @@ class BlockedUsersScreenViewModel: BlockedUsersScreenViewModelType, BlockedUsers
|
||||
|
||||
/// The client proxy isn't Sendable, fetch through this helper so that it
|
||||
/// never leaves the main actor when running calls in parallel.
|
||||
private func profile(for userID: String) async -> UserProfileProxy {
|
||||
private func profile(for userID: String) async -> UserProfile {
|
||||
switch await clientProxy.profile(for: userID) {
|
||||
case .success(let profile): profile
|
||||
case .failure: UserProfileProxy(userID: userID)
|
||||
case .failure: UserProfile(userID: userID)
|
||||
}
|
||||
}
|
||||
|
||||
private func unblockUser(_ user: UserProfileProxy) {
|
||||
private func unblockUser(_ user: UserProfile) {
|
||||
showLoadingIndicator()
|
||||
state.processingUserID = user.userID
|
||||
state.processingUserID = user.id
|
||||
|
||||
Task {
|
||||
if case .failure = await clientProxy.unignoreUser(user.userID) {
|
||||
if case .failure = await clientProxy.unignoreUser(user.id) {
|
||||
state.bindings.alertInfo = .init(id: .error)
|
||||
}
|
||||
|
||||
|
||||
@@ -33,20 +33,20 @@ struct BlockedUsersScreen: View {
|
||||
} else {
|
||||
Form {
|
||||
ForEach(context.viewState.blockedUsers, id: \.self) { user in
|
||||
ListRow(label: .avatar(title: user.displayName ?? user.userID,
|
||||
description: user.displayName != nil ? user.userID : nil,
|
||||
ListRow(label: .avatar(title: user.displayName ?? user.id,
|
||||
description: user.displayName != nil ? user.id : nil,
|
||||
icon: avatar(for: user)),
|
||||
details: .isWaiting(context.viewState.processingUserID == user.userID),
|
||||
details: .isWaiting(context.viewState.processingUserID == user.id),
|
||||
kind: .button { context.send(viewAction: .unblockUser(user)) })
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private func avatar(for user: UserProfileProxy) -> some View {
|
||||
private func avatar(for user: UserProfile) -> some View {
|
||||
LoadableAvatarImage(url: user.avatarURL,
|
||||
name: user.displayName,
|
||||
contentID: user.userID,
|
||||
contentID: user.id,
|
||||
avatarSize: .user(on: .blockedUsers),
|
||||
mediaProvider: context.mediaProvider)
|
||||
.accessibilityHidden(true)
|
||||
|
||||
@@ -20,7 +20,7 @@ enum InviteUsersScreenViewModelAction {
|
||||
}
|
||||
|
||||
enum InviteUsersScreenRoomType {
|
||||
case draft(mandatoryInvitees: [UserProfileProxy])
|
||||
case draft(mandatoryInvitees: [UserProfile])
|
||||
case existingRoom(roomProxy: JoinedRoomProxyProtocol)
|
||||
}
|
||||
|
||||
@@ -29,10 +29,10 @@ struct InviteUsersScreenViewState: BindableState {
|
||||
|
||||
var usersSection: UserDiscoverySection = .init(type: .suggestions, users: [])
|
||||
|
||||
var selectedUsers: [UserProfileProxy] = []
|
||||
var mandatoryInvitees: [UserProfileProxy] = []
|
||||
var selectedUsers: [UserProfile] = []
|
||||
var mandatoryInvitees: [UserProfile] = []
|
||||
var membershipState: [String: MembershipState] = .init()
|
||||
var usersToConfirm: [UserProfileProxy] = []
|
||||
var usersToConfirm: [UserProfile] = []
|
||||
|
||||
var isSearching = false
|
||||
|
||||
@@ -44,11 +44,11 @@ struct InviteUsersScreenViewState: BindableState {
|
||||
selectedUsers.contains { !isInviteeMandatory($0) }
|
||||
}
|
||||
|
||||
func isUserSelected(_ user: UserProfileProxy) -> Bool {
|
||||
isUserDisabled(user) || selectedUsers.contains { $0.userID == user.userID }
|
||||
func isUserSelected(_ user: UserProfile) -> Bool {
|
||||
isUserDisabled(user) || selectedUsers.contains { $0.id == user.id }
|
||||
}
|
||||
|
||||
func isUserDisabled(_ user: UserProfileProxy) -> Bool {
|
||||
func isUserDisabled(_ user: UserProfile) -> Bool {
|
||||
if isInviteeMandatory(user) {
|
||||
return true
|
||||
}
|
||||
@@ -56,12 +56,12 @@ struct InviteUsersScreenViewState: BindableState {
|
||||
return membershipState == .invite || membershipState == .join
|
||||
}
|
||||
|
||||
func isInviteeMandatory(_ user: UserProfileProxy) -> Bool {
|
||||
mandatoryInvitees.contains { $0.userID == user.userID }
|
||||
func isInviteeMandatory(_ user: UserProfile) -> Bool {
|
||||
mandatoryInvitees.contains { $0.id == user.id }
|
||||
}
|
||||
|
||||
func membershipState(_ user: UserProfileProxy) -> MembershipState? {
|
||||
membershipState[user.userID]
|
||||
func membershipState(_ user: UserProfile) -> MembershipState? {
|
||||
membershipState[user.id]
|
||||
}
|
||||
|
||||
let isSkippable: Bool
|
||||
@@ -83,5 +83,5 @@ enum InviteUsersScreenViewAction {
|
||||
case proceed
|
||||
case removeUnknownUsers
|
||||
case confirmUnknownUsers
|
||||
case toggleUser(UserProfileProxy)
|
||||
case toggleUser(UserProfile)
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ class InviteUsersScreenViewModel: InviteUsersScreenViewModelType, InviteUsersScr
|
||||
private let userIndicatorController: UserIndicatorControllerProtocol
|
||||
private let appSettings: AppSettings
|
||||
|
||||
private var suggestedUsers = [UserProfileProxy]()
|
||||
private var suggestedUsers = [UserProfile]()
|
||||
|
||||
private let actionsSubject: PassthroughSubject<InviteUsersScreenViewModelAction, Never> = .init()
|
||||
var actions: AnyPublisher<InviteUsersScreenViewModelAction, Never> {
|
||||
@@ -38,7 +38,7 @@ class InviteUsersScreenViewModel: InviteUsersScreenViewModelType, InviteUsersScr
|
||||
self.userIndicatorController = userIndicatorController
|
||||
self.appSettings = appSettings
|
||||
|
||||
let mandatoryInvitees: [UserProfileProxy] = if case .draft(let invitees) = roomType {
|
||||
let mandatoryInvitees: [UserProfile] = if case .draft(let invitees) = roomType {
|
||||
invitees
|
||||
} else {
|
||||
[]
|
||||
@@ -70,12 +70,12 @@ class InviteUsersScreenViewModel: InviteUsersScreenViewModelType, InviteUsersScr
|
||||
case .proceed:
|
||||
switch roomType {
|
||||
case .draft:
|
||||
createDraftRoom(mandatoryUserIDs: state.selectedUsers.map(\.userID))
|
||||
createDraftRoom(mandatoryUserIDs: state.selectedUsers.map(\.id))
|
||||
case .existingRoom(let roomProxy):
|
||||
guard roomProxy.details.historySharingState != RoomHistorySharingState.hidden,
|
||||
!state.usersToConfirm.isEmpty,
|
||||
!state.isSkippable else {
|
||||
inviteUsers(state.selectedUsers.map(\.userID), roomProxy: roomProxy)
|
||||
inviteUsers(state.selectedUsers.map(\.id), roomProxy: roomProxy)
|
||||
return
|
||||
}
|
||||
state.bindings.presentConfirmationDialog = true
|
||||
@@ -83,14 +83,14 @@ class InviteUsersScreenViewModel: InviteUsersScreenViewModelType, InviteUsersScr
|
||||
case .removeUnknownUsers:
|
||||
state.bindings.presentConfirmationDialog = false
|
||||
state.selectedUsers.removeAll { user in
|
||||
state.usersToConfirm.contains { $0.userID == user.userID }
|
||||
state.usersToConfirm.contains { $0.id == user.id }
|
||||
}
|
||||
state.usersToConfirm = []
|
||||
case .confirmUnknownUsers:
|
||||
state.bindings.presentConfirmationDialog = false
|
||||
state.usersToConfirm = []
|
||||
if case .existingRoom(let roomProxy) = roomType {
|
||||
inviteUsers(state.selectedUsers.map(\.userID), roomProxy: roomProxy)
|
||||
inviteUsers(state.selectedUsers.map(\.id), roomProxy: roomProxy)
|
||||
}
|
||||
case .toggleUser(let user):
|
||||
toggleUser(user)
|
||||
@@ -99,16 +99,16 @@ class InviteUsersScreenViewModel: InviteUsersScreenViewModelType, InviteUsersScr
|
||||
|
||||
// MARK: - Private
|
||||
|
||||
private func toggleUser(_ user: UserProfileProxy) {
|
||||
private func toggleUser(_ user: UserProfile) {
|
||||
guard !state.isInviteeMandatory(user) else { return }
|
||||
|
||||
if state.selectedUsers.contains(user) {
|
||||
state.selectedUsers.removeAll { $0.userID == user.userID }
|
||||
state.selectedUsers.removeAll { $0.id == user.id }
|
||||
} else {
|
||||
state.selectedUsers.append(user)
|
||||
withElementAnimation(.easeInOut) { state.bindings.selectedUsersPosition = user.userID }
|
||||
withElementAnimation(.easeInOut) { state.bindings.selectedUsersPosition = user.id }
|
||||
Task {
|
||||
let identityUnknown = if case .success(let identity) = await self.clientProxy.userIdentity(for: user.userID, fallBackToServer: false) {
|
||||
let identityUnknown = if case .success(let identity) = await self.clientProxy.userIdentity(for: user.id, fallBackToServer: false) {
|
||||
identity == nil
|
||||
} else {
|
||||
true
|
||||
|
||||
+2
-2
@@ -12,7 +12,7 @@ struct InviteUsersConfirmationSheetView: View {
|
||||
@ObservedObject var context: InviteUsersScreenViewModel.Context
|
||||
|
||||
/// The users whose identities we wish the user to confirm.
|
||||
var users: [UserProfileProxy]
|
||||
var users: [UserProfile]
|
||||
|
||||
var body: some View {
|
||||
FullscreenDialog(topPadding: 24, horizontalPadding: 24) {
|
||||
@@ -22,7 +22,7 @@ struct InviteUsersConfirmationSheetView: View {
|
||||
icon: \.userAddSolid,
|
||||
iconStyle: .defaultSolid)
|
||||
VStack(spacing: 0) {
|
||||
ForEach(users, id: \.userID) { user in
|
||||
ForEach(users, id: \.id) { user in
|
||||
UserProfileListRow(user: user,
|
||||
membership: nil,
|
||||
mediaProvider: context.mediaProvider,
|
||||
|
||||
@@ -83,7 +83,7 @@ struct InviteUsersScreen: View {
|
||||
private var usersSection: some View {
|
||||
if !context.viewState.usersSection.users.isEmpty {
|
||||
Section {
|
||||
ForEach(context.viewState.usersSection.users, id: \.userID) { user in
|
||||
ForEach(context.viewState.usersSection.users, id: \.id) { user in
|
||||
UserProfileListRow(user: user,
|
||||
membership: context.viewState.membershipState(user),
|
||||
mediaProvider: context.mediaProvider,
|
||||
@@ -109,7 +109,7 @@ struct InviteUsersScreen: View {
|
||||
private var selectedUsersSection: some View {
|
||||
ScrollView(.horizontal, showsIndicators: false) {
|
||||
HStack(spacing: 8) {
|
||||
ForEach(context.viewState.selectedUsers, id: \.userID) { user in
|
||||
ForEach(context.viewState.selectedUsers, id: \.id) { user in
|
||||
InviteUsersScreenSelectedItem(user: user,
|
||||
mediaProvider: context.mediaProvider,
|
||||
isLocked: context.viewState.isInviteeMandatory(user)) {
|
||||
@@ -150,7 +150,7 @@ struct InviteUsersScreen: View {
|
||||
}
|
||||
}
|
||||
|
||||
private func deselect(_ user: UserProfileProxy) {
|
||||
private func deselect(_ user: UserProfile) {
|
||||
context.send(viewAction: .toggleUser(user))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ import Compound
|
||||
import SwiftUI
|
||||
|
||||
struct InviteUsersScreenSelectedItem: View {
|
||||
let user: UserProfileProxy
|
||||
let user: UserProfile
|
||||
let mediaProvider: MediaProviderProtocol?
|
||||
var isLocked = false
|
||||
let dismissAction: () -> Void
|
||||
@@ -20,7 +20,7 @@ struct InviteUsersScreenSelectedItem: View {
|
||||
avatar
|
||||
.accessibilityHidden(true)
|
||||
|
||||
Text(user.displayName ?? user.userID)
|
||||
Text(user.displayName ?? user.id)
|
||||
.font(.compound.bodySM)
|
||||
.foregroundColor(.compound.textSecondary)
|
||||
.lineLimit(1)
|
||||
@@ -39,7 +39,7 @@ struct InviteUsersScreenSelectedItem: View {
|
||||
var avatar: some View {
|
||||
let avatarImage = LoadableAvatarImage(url: user.avatarURL,
|
||||
name: user.displayName,
|
||||
contentID: user.userID,
|
||||
contentID: user.id,
|
||||
avatarSize: .user(on: .inviteUsers),
|
||||
mediaProvider: mediaProvider)
|
||||
if isLocked {
|
||||
@@ -58,12 +58,12 @@ struct InviteUsersScreenSelectedItem: View {
|
||||
}
|
||||
|
||||
struct InviteUsersScreenSelectedItem_Previews: PreviewProvider, TestablePreview {
|
||||
static let people: [UserProfileProxy] = [.mockAlice, .mockVerbose]
|
||||
static let people: [UserProfile] = [.mockAlice, .mockVerbose]
|
||||
|
||||
static var previews: some View {
|
||||
ScrollView(.horizontal) {
|
||||
HStack(spacing: 8) {
|
||||
ForEach(people, id: \.userID) { user in
|
||||
ForEach(people, id: \.id) { user in
|
||||
InviteUsersScreenSelectedItem(user: user, mediaProvider: MediaProviderMock(.init())) { }
|
||||
.frame(width: 80)
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ struct JoinRoomScreenRoomDetails {
|
||||
let canonicalAlias: String?
|
||||
let avatar: RoomAvatar?
|
||||
let memberCount: Int?
|
||||
let heroes: [UserProfileProxy]
|
||||
let heroes: [UserProfile]
|
||||
let inviter: RoomInviterDetails?
|
||||
let isDirect: Bool?
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ struct LocationSharingScreenViewState: BindableState {
|
||||
self.mapURLBuilder = mapURLBuilder
|
||||
self.ownUserID = ownUserID
|
||||
|
||||
let initialProfile: UserProfileProxy = switch interactionMode {
|
||||
let initialProfile: UserProfile = switch interactionMode {
|
||||
case .viewStatic(let locationData):
|
||||
.init(sender: locationData.sender)
|
||||
case .viewLive(let sender, _):
|
||||
@@ -64,7 +64,7 @@ struct LocationSharingScreenViewState: BindableState {
|
||||
case .picker:
|
||||
.init(userID: ownUserID)
|
||||
}
|
||||
userProfiles = [initialProfile.userID: initialProfile]
|
||||
userProfiles = [initialProfile.id: initialProfile]
|
||||
|
||||
if case .viewLive(_, let initialLiveLocationShare) = interactionMode, let initialLiveLocationShare {
|
||||
liveLocationShares = [initialLiveLocationShare]
|
||||
@@ -79,7 +79,7 @@ struct LocationSharingScreenViewState: BindableState {
|
||||
let interactionMode: LocationSharingInteractionMode
|
||||
let mapURLBuilder: MapTilerURLBuilderProtocol
|
||||
let ownUserID: String
|
||||
var userProfiles: [String: UserProfileProxy]
|
||||
var userProfiles: [String: UserProfile]
|
||||
var liveLocationShares: [LiveLocationShare] = []
|
||||
var isStoppingLiveLocation = false
|
||||
/// Whether this device has an active live location sharing session in the room.
|
||||
@@ -103,10 +103,10 @@ struct LocationSharingScreenViewState: BindableState {
|
||||
return nil
|
||||
}
|
||||
|
||||
let profile = userProfiles[share.userID] ?? UserProfileProxy(userID: share.userID)
|
||||
let profile = userProfiles[share.userID] ?? UserProfile(userID: share.userID)
|
||||
let kind = LocationMarkerKind.liveUser(profile)
|
||||
let coordinate = CLLocationCoordinate2D(latitude: geoURI.latitude, longitude: geoURI.longitude)
|
||||
return LocationAnnotation(id: profile.userID, coordinate: coordinate, kind: kind)
|
||||
return LocationAnnotation(id: profile.id, coordinate: coordinate, kind: kind)
|
||||
}
|
||||
case .picker:
|
||||
return []
|
||||
@@ -287,8 +287,8 @@ extension AlertInfo where T == LocationSharingViewAlert {
|
||||
|
||||
enum LocationMarkerKind: Equatable {
|
||||
case pin
|
||||
case staticUser(UserProfileProxy)
|
||||
case liveUser(UserProfileProxy)
|
||||
case staticUser(UserProfile)
|
||||
case liveUser(UserProfile)
|
||||
case placeholder
|
||||
|
||||
var id: String {
|
||||
@@ -296,7 +296,7 @@ enum LocationMarkerKind: Equatable {
|
||||
case .pin, .placeholder:
|
||||
UUID().uuidString
|
||||
case .staticUser(let profile), .liveUser(let profile):
|
||||
profile.userID
|
||||
profile.id
|
||||
}
|
||||
}
|
||||
|
||||
@@ -309,7 +309,7 @@ enum LocationMarkerKind: Equatable {
|
||||
}
|
||||
}
|
||||
|
||||
var userProfile: UserProfileProxy? {
|
||||
var userProfile: UserProfile? {
|
||||
switch self {
|
||||
case .pin, .placeholder:
|
||||
nil
|
||||
|
||||
@@ -194,11 +194,11 @@ class LocationSharingScreenViewModel: LocationSharingScreenViewModelType, Locati
|
||||
private func updateUserProfiles(members: [RoomMemberProxyProtocol]) {
|
||||
switch state.interactionMode {
|
||||
case .picker:
|
||||
let ownUser = members.first { $0.userID == roomProxy.ownUserID }.map(UserProfileProxy.init) ?? .init(userID: roomProxy.ownUserID)
|
||||
state.userProfiles = [ownUser.userID: ownUser]
|
||||
let ownUser = members.first { $0.userID == roomProxy.ownUserID }.map(UserProfile.init) ?? .init(userID: roomProxy.ownUserID)
|
||||
state.userProfiles = [ownUser.id: ownUser]
|
||||
case .viewStatic(let location):
|
||||
let sender = members.first { $0.userID == location.sender.id }.map(UserProfileProxy.init) ?? .init(sender: location.sender)
|
||||
state.userProfiles = [sender.userID: sender]
|
||||
let sender = members.first { $0.userID == location.sender.id }.map(UserProfile.init) ?? .init(sender: location.sender)
|
||||
state.userProfiles = [sender.id: sender]
|
||||
case .viewLive(let sender, _):
|
||||
var userIDs = Set(state.liveLocationShares.map(\.userID))
|
||||
if let senderID = sender?.id {
|
||||
@@ -206,9 +206,9 @@ class LocationSharingScreenViewModel: LocationSharingScreenViewModelType, Locati
|
||||
}
|
||||
state.userProfiles = userIDs.reduce(into: [:]) { dict, userID in
|
||||
if let member = members.first(where: { $0.userID == userID }) {
|
||||
dict[userID] = UserProfileProxy(member: member)
|
||||
dict[userID] = UserProfile(member: member)
|
||||
} else {
|
||||
dict[userID] = UserProfileProxy(userID: userID)
|
||||
dict[userID] = UserProfile(userID: userID)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ struct LocationShareSheet: View {
|
||||
}
|
||||
|
||||
private var senderName: String? {
|
||||
annotation.kind.displayName ?? annotation.kind.userProfile?.userID
|
||||
annotation.kind.displayName ?? annotation.kind.userProfile?.id
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
@@ -40,8 +40,8 @@ struct LocationShareSheet: View {
|
||||
// MARK: - Previews
|
||||
|
||||
struct LocationShareSheet_Previews: PreviewProvider {
|
||||
static let profile = UserProfileProxy(userID: "@alice:example.com", displayName: "Alice")
|
||||
static let annotation = LocationAnnotation(id: profile.userID,
|
||||
static let profile = UserProfile(userID: "@alice:example.com", displayName: "Alice")
|
||||
static let annotation = LocationAnnotation(id: profile.id,
|
||||
coordinate: .init(latitude: 51.509865, longitude: -0.118092),
|
||||
kind: .liveUser(profile))
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ struct StaticLocationSheet: View {
|
||||
longitude: location.geoURI.longitude)))
|
||||
} label: {
|
||||
UserLocationCell(profile: profile,
|
||||
isOwnUser: context.viewState.isOwnUser(profile.userID),
|
||||
isOwnUser: context.viewState.isOwnUser(profile.id),
|
||||
kind: .static(isUserLocation: location.kind == .sender,
|
||||
timestamp: location.timestamp),
|
||||
mediaProvider: context.mediaProvider,
|
||||
|
||||
@@ -9,7 +9,7 @@ import Compound
|
||||
import SwiftUI
|
||||
|
||||
struct UserLocationCell: View {
|
||||
let profile: UserProfileProxy
|
||||
let profile: UserProfile
|
||||
let isOwnUser: Bool
|
||||
let kind: Kind
|
||||
var mediaProvider: MediaProviderProtocol?
|
||||
@@ -23,7 +23,7 @@ struct UserLocationCell: View {
|
||||
}
|
||||
|
||||
private var name: String {
|
||||
isOwnUser ? L10n.commonYou : profile.displayName ?? profile.userID
|
||||
isOwnUser ? L10n.commonYou : profile.displayName ?? profile.id
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
|
||||
+7
-7
@@ -30,18 +30,18 @@ struct SessionVerificationRequestDetailsView: View {
|
||||
HStack(spacing: 12) {
|
||||
LoadableAvatarImage(url: details.senderProfile.avatarURL,
|
||||
name: details.senderProfile.displayName,
|
||||
contentID: details.senderProfile.userID,
|
||||
contentID: details.senderProfile.id,
|
||||
avatarSize: .user(on: .sessionVerification),
|
||||
mediaProvider: mediaProvider)
|
||||
.accessibilityHidden(true)
|
||||
|
||||
VStack(alignment: .leading, spacing: 0) {
|
||||
Text(details.senderProfile.displayName ?? details.senderProfile.userID)
|
||||
Text(details.senderProfile.displayName ?? details.senderProfile.id)
|
||||
.font(.compound.bodySM)
|
||||
.foregroundColor(.compound.textSecondary)
|
||||
|
||||
if details.senderProfile.displayName != nil {
|
||||
Text(details.senderProfile.userID)
|
||||
Text(details.senderProfile.id)
|
||||
.font(.compound.bodyMD)
|
||||
.foregroundColor(.compound.textPrimary)
|
||||
}
|
||||
@@ -66,7 +66,7 @@ struct SessionVerificationRequestDetailsView: View {
|
||||
.clipShape(RoundedRectangle(cornerRadius: 8))
|
||||
|
||||
let displayName = isUserVerification ? details.senderProfile.displayName : details.deviceDisplayName
|
||||
Text(displayName ?? details.senderProfile.userID)
|
||||
Text(displayName ?? details.senderProfile.id)
|
||||
.font(.compound.bodyMDSemibold)
|
||||
.foregroundColor(.compound.textPrimary)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
@@ -110,9 +110,9 @@ struct SessionVerificationRequestDetailsView: View {
|
||||
}
|
||||
|
||||
struct SessionVerificationRequestDetailsView_Previews: PreviewProvider, TestablePreview {
|
||||
static let details = SessionVerificationRequestDetails(senderProfile: UserProfileProxy(userID: "@bob:matrix.org",
|
||||
displayName: "Billy bob",
|
||||
avatarURL: .mockMXCUserAvatar),
|
||||
static let details = SessionVerificationRequestDetails(senderProfile: UserProfile(userID: "@bob:matrix.org",
|
||||
displayName: "Billy bob",
|
||||
avatarURL: .mockMXCUserAvatar),
|
||||
flowID: "123",
|
||||
deviceID: "CODEMISTAKE",
|
||||
deviceDisplayName: "Bob's Element X iOS",
|
||||
|
||||
+3
-3
@@ -232,9 +232,9 @@ struct SessionVerification_Previews: PreviewProvider, TestablePreview {
|
||||
sessionVerificationScreen(state: .initial, flow: .userInitiator(userID: "@bob:matrix.org"))
|
||||
.previewDisplayName("Initial - User Initiator")
|
||||
|
||||
let details = SessionVerificationRequestDetails(senderProfile: UserProfileProxy(userID: "@bob:matrix.org",
|
||||
displayName: "Billy Bob",
|
||||
avatarURL: .mockMXCUserAvatar),
|
||||
let details = SessionVerificationRequestDetails(senderProfile: UserProfile(userID: "@bob:matrix.org",
|
||||
displayName: "Billy Bob",
|
||||
avatarURL: .mockMXCUserAvatar),
|
||||
flowID: "123",
|
||||
deviceID: "CODEMISTAKE",
|
||||
deviceDisplayName: "Bob's Element X iOS",
|
||||
|
||||
@@ -26,7 +26,7 @@ enum RoomDetailsScreenCoordinatorAction {
|
||||
case presentRoomDetailsEditScreen
|
||||
case presentNotificationSettingsScreen
|
||||
case presentInviteUsersScreen
|
||||
case presentInviteToNewRoom(invitee: UserProfileProxy)
|
||||
case presentInviteToNewRoom(invitee: UserProfile)
|
||||
case presentPollsHistory
|
||||
case presentRolesAndPermissionsScreen
|
||||
case presentCall(isVoiceCall: Bool)
|
||||
|
||||
@@ -18,7 +18,7 @@ enum RoomDetailsScreenViewModelAction: Equatable {
|
||||
case requestMemberDetailsPresentation
|
||||
case requestRecipientDetailsPresentation(userID: String)
|
||||
case requestInvitePeoplePresentation
|
||||
case requestInviteToNewRoomPresentation(selectedInvitee: UserProfileProxy)
|
||||
case requestInviteToNewRoomPresentation(selectedInvitee: UserProfile)
|
||||
case leftRoom
|
||||
case requestEditDetailsPresentation
|
||||
case requestPollsHistoryPresentation
|
||||
|
||||
+1
-1
@@ -202,7 +202,7 @@ class RoomMemberDetailsScreenViewModel: RoomMemberDetailsScreenViewModelType, Ro
|
||||
} else if roomProxy.details.historySharingState != RoomHistorySharingState.hidden {
|
||||
Task {
|
||||
let identity = await self.userSession.clientProxy.userIdentity(for: roomMemberProxy.userID, fallBackToServer: false)
|
||||
let user: UserProfileProxy = .init(userID: roomMemberProxy.userID, displayName: roomMemberProxy.displayName, avatarURL: roomMemberProxy.avatarURL)
|
||||
let user: UserProfile = .init(userID: roomMemberProxy.userID, displayName: roomMemberProxy.displayName, avatarURL: roomMemberProxy.avatarURL)
|
||||
let isUnknown = if case .success(let identity) = identity {
|
||||
identity == nil
|
||||
} else {
|
||||
|
||||
@@ -59,7 +59,7 @@ struct RoomMemberDetailsScreen: View {
|
||||
.padding(.top, 24)
|
||||
}
|
||||
} else {
|
||||
AvatarHeaderView(user: UserProfileProxy(userID: context.viewState.userID),
|
||||
AvatarHeaderView(user: UserProfile(userID: context.viewState.userID),
|
||||
isVerified: context.viewState.showVerifiedBadge,
|
||||
avatarSize: .user(on: .memberDetails),
|
||||
mediaProvider: context.mediaProvider) { }
|
||||
|
||||
@@ -85,7 +85,7 @@ class SearchScreenViewModel: SearchScreenViewModelType, SearchScreenViewModelPro
|
||||
// Show the matrix identifier as the subtitle: the other member's user ID for DMs,
|
||||
// otherwise the room's canonical alias.
|
||||
let identifier = if summary.isDirect {
|
||||
summary.heroes.first?.userID ?? summary.canonicalAlias
|
||||
summary.heroes.first?.id ?? summary.canonicalAlias
|
||||
} else {
|
||||
summary.canonicalAlias
|
||||
}
|
||||
|
||||
@@ -50,8 +50,8 @@ struct StartChatScreenViewStateBindings {
|
||||
enum StartChatScreenViewAction {
|
||||
case close
|
||||
case createRoom
|
||||
case createDM(user: UserProfileProxy)
|
||||
case selectUser(UserProfileProxy)
|
||||
case createDM(user: UserProfile)
|
||||
case selectUser(UserProfile)
|
||||
case joinRoomByAddress
|
||||
case openRoomDirectorySearch
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ class StartChatScreenViewModel: StartChatScreenViewModelType, StartChatScreenVie
|
||||
private let userDiscoveryService: UserDiscoveryServiceProtocol
|
||||
private let appSettings: AppSettings
|
||||
|
||||
private var suggestedUsers = [UserProfileProxy]()
|
||||
private var suggestedUsers = [UserProfile]()
|
||||
|
||||
private let actionsSubject: PassthroughSubject<StartChatScreenViewModelAction, Never> = .init()
|
||||
var actions: AnyPublisher<StartChatScreenViewModelAction, Never> {
|
||||
@@ -61,7 +61,7 @@ class StartChatScreenViewModel: StartChatScreenViewModelType, StartChatScreenVie
|
||||
case .selectUser(let user):
|
||||
showLoadingIndicator(delay: .milliseconds(200))
|
||||
|
||||
let currentDirectRoom = userSession.clientProxy.directRoomForUserID(user.userID)
|
||||
let currentDirectRoom = userSession.clientProxy.directRoomForUserID(user.id)
|
||||
switch currentDirectRoom {
|
||||
case .success(.some(let roomId)):
|
||||
hideLoadingIndicator()
|
||||
@@ -69,7 +69,7 @@ class StartChatScreenViewModel: StartChatScreenViewModelType, StartChatScreenVie
|
||||
case .success:
|
||||
Task {
|
||||
// If an error occured while fetching the identity, assume they are unknown.
|
||||
let isUnknown = if case .success(let identity) = await self.userSession.clientProxy.userIdentity(for: user.userID, fallBackToServer: false) {
|
||||
let isUnknown = if case .success(let identity) = await self.userSession.clientProxy.userIdentity(for: user.id, fallBackToServer: false) {
|
||||
identity == nil
|
||||
} else {
|
||||
true
|
||||
@@ -186,12 +186,12 @@ class StartChatScreenViewModel: StartChatScreenViewModelType, StartChatScreenVie
|
||||
}
|
||||
}
|
||||
|
||||
private func createDirectRoom(user: UserProfileProxy) async {
|
||||
private func createDirectRoom(user: UserProfile) async {
|
||||
defer {
|
||||
hideLoadingIndicator()
|
||||
}
|
||||
showLoadingIndicator()
|
||||
switch await userSession.clientProxy.createDirectRoom(with: user.userID, expectedRoomName: user.displayName) {
|
||||
switch await userSession.clientProxy.createDirectRoom(with: user.id, expectedRoomName: user.displayName) {
|
||||
case .success(let roomId):
|
||||
analytics.trackCreatedRoom(isDM: true)
|
||||
actionsSubject.send(.showRoom(roomID: roomId))
|
||||
|
||||
@@ -112,7 +112,7 @@ struct StartChatScreen: View {
|
||||
private var usersSection: some View {
|
||||
if !context.viewState.usersSection.users.isEmpty {
|
||||
Section {
|
||||
ForEach(context.viewState.usersSection.users, id: \.userID) { user in
|
||||
ForEach(context.viewState.usersSection.users, id: \.id) { user in
|
||||
UserProfileListRow(user: user,
|
||||
membership: nil,
|
||||
mediaProvider: context.mediaProvider,
|
||||
|
||||
@@ -19,7 +19,7 @@ struct UserProfileScreenViewState: BindableState {
|
||||
let isOwnUser: Bool
|
||||
let isPresentedModally: Bool
|
||||
|
||||
var userProfile: UserProfileProxy?
|
||||
var userProfile: UserProfile?
|
||||
var isIdentityKnown = false
|
||||
var isVerified: Bool?
|
||||
var permalink: URL?
|
||||
|
||||
@@ -77,7 +77,7 @@ class UserProfileScreenViewModel: UserProfileScreenViewModelType, UserProfileScr
|
||||
// The proxies aren't Sendable, fetch through these helpers so that
|
||||
// they never leave the main actor when running calls in parallel.
|
||||
|
||||
private func fetchProfile() async -> Result<UserProfileProxy, ClientProxyError> {
|
||||
private func fetchProfile() async -> Result<UserProfile, ClientProxyError> {
|
||||
await userSession.clientProxy.profile(for: state.userID)
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ class UserProfileScreenViewModel: UserProfileScreenViewModelType, UserProfileScr
|
||||
state.userProfile = userProfile
|
||||
state.permalink = (try? matrixToUserPermalink(userId: state.userID)).flatMap(URL.init(string:))
|
||||
|
||||
switch userSession.clientProxy.directRoomForUserID(userProfile.userID) {
|
||||
switch userSession.clientProxy.directRoomForUserID(userProfile.id) {
|
||||
case .success(let roomID):
|
||||
state.dmRoomID = roomID
|
||||
case .failure:
|
||||
@@ -133,13 +133,13 @@ class UserProfileScreenViewModel: UserProfileScreenViewModelType, UserProfileScr
|
||||
showLoadingIndicator(allowsInteraction: false)
|
||||
defer { hideLoadingIndicator() }
|
||||
|
||||
switch userSession.clientProxy.directRoomForUserID(userProfile.userID) {
|
||||
switch userSession.clientProxy.directRoomForUserID(userProfile.id) {
|
||||
case .success(let roomID):
|
||||
if let roomID {
|
||||
actionsSubject.send(.openDirectChat(roomID: roomID))
|
||||
} else {
|
||||
Task {
|
||||
let isUnknown = if case let .success(identity) = await userSession.clientProxy.userIdentity(for: userProfile.userID, fallBackToServer: false) {
|
||||
let isUnknown = if case let .success(identity) = await userSession.clientProxy.userIdentity(for: userProfile.id, fallBackToServer: false) {
|
||||
identity == nil
|
||||
} else {
|
||||
true
|
||||
@@ -158,7 +158,7 @@ class UserProfileScreenViewModel: UserProfileScreenViewModelType, UserProfileScr
|
||||
showLoadingIndicator(allowsInteraction: false)
|
||||
defer { hideLoadingIndicator() }
|
||||
|
||||
switch await userSession.clientProxy.createDirectRoom(with: userProfile.userID, expectedRoomName: userProfile.displayName) {
|
||||
switch await userSession.clientProxy.createDirectRoom(with: userProfile.id, expectedRoomName: userProfile.displayName) {
|
||||
case .success(let roomID):
|
||||
analytics.trackCreatedRoom(isDM: true)
|
||||
actionsSubject.send(.openDirectChat(roomID: roomID))
|
||||
|
||||
@@ -45,7 +45,7 @@ struct UserProfileScreen: View {
|
||||
otherUserFooter
|
||||
}
|
||||
} else {
|
||||
AvatarHeaderView(user: UserProfileProxy(userID: context.viewState.userID),
|
||||
AvatarHeaderView(user: UserProfile(userID: context.viewState.userID),
|
||||
isVerified: context.viewState.showVerifiedBadge,
|
||||
avatarSize: .user(on: .memberDetails),
|
||||
mediaProvider: context.mediaProvider) { }
|
||||
|
||||
@@ -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