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:
Doug
2026-07-01 15:18:03 +01:00
committed by Doug
parent bdf53b64a8
commit 3ef66cdd05
55 changed files with 203 additions and 209 deletions
@@ -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
@@ -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 {
@@ -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",
@@ -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
@@ -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) { }