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)