Combine the user's own display name/avatar into a single profile.

This is in preparation for adding the user status fields into the profile.
This commit is contained in:
Doug
2026-07-01 16:45:42 +01:00
committed by Doug
parent b8860baf49
commit ace05b97d0
17 changed files with 88 additions and 175 deletions
@@ -2291,16 +2291,11 @@ nonisolated class ClientProxyMock: ClientProxyProtocol, @unchecked Sendable {
}
nonisolated(unsafe) var underlyingCanDeactivateAccount: Bool!
nonisolated(unsafe) var userIDServerName: String?
var userDisplayNamePublisher: CurrentValuePublisher<String?, Never> {
get { return underlyingUserDisplayNamePublisher }
set(value) { underlyingUserDisplayNamePublisher = value }
var userProfilePublisher: CurrentValuePublisher<UserProfile, Never> {
get { return underlyingUserProfilePublisher }
set(value) { underlyingUserProfilePublisher = value }
}
nonisolated(unsafe) var underlyingUserDisplayNamePublisher: CurrentValuePublisher<String?, Never>!
var userAvatarURLPublisher: CurrentValuePublisher<URL?, Never> {
get { return underlyingUserAvatarURLPublisher }
set(value) { underlyingUserAvatarURLPublisher = value }
}
nonisolated(unsafe) var underlyingUserAvatarURLPublisher: CurrentValuePublisher<URL?, Never>!
nonisolated(unsafe) var underlyingUserProfilePublisher: CurrentValuePublisher<UserProfile, Never>!
var ignoredUsersPublisher: CurrentValuePublisher<[String]?, Never> {
get { return underlyingIgnoredUsersPublisher }
set(value) { underlyingIgnoredUsersPublisher = value }
@@ -3174,33 +3169,33 @@ nonisolated class ClientProxyMock: ClientProxyProtocol, @unchecked Sendable {
return reportRoomForIdentifierReasonReturnValue
}
}
//MARK: - loadUserDisplayName
//MARK: - loadUserProfile
private let loadUserDisplayNameCallsCountLock = NSLock()
private nonisolated(unsafe) var loadUserDisplayNameUnderlyingCallsCount = 0
var loadUserDisplayNameCallsCount: Int {
get { loadUserDisplayNameCallsCountLock.withLock { loadUserDisplayNameUnderlyingCallsCount } }
set { loadUserDisplayNameCallsCountLock.withLock { loadUserDisplayNameUnderlyingCallsCount = newValue } }
private let loadUserProfileCallsCountLock = NSLock()
private nonisolated(unsafe) var loadUserProfileUnderlyingCallsCount = 0
var loadUserProfileCallsCount: Int {
get { loadUserProfileCallsCountLock.withLock { loadUserProfileUnderlyingCallsCount } }
set { loadUserProfileCallsCountLock.withLock { loadUserProfileUnderlyingCallsCount = newValue } }
}
var loadUserDisplayNameCalled: Bool {
return loadUserDisplayNameCallsCount > 0
var loadUserProfileCalled: Bool {
return loadUserProfileCallsCount > 0
}
private let loadUserDisplayNameReturnValueLock = NSLock()
private nonisolated(unsafe) var loadUserDisplayNameUnderlyingReturnValue: Result<Void, ClientProxyError>!
var loadUserDisplayNameReturnValue: Result<Void, ClientProxyError>! {
get { loadUserDisplayNameReturnValueLock.withLock { loadUserDisplayNameUnderlyingReturnValue } }
set { loadUserDisplayNameReturnValueLock.withLock { loadUserDisplayNameUnderlyingReturnValue = newValue } }
private let loadUserProfileReturnValueLock = NSLock()
private nonisolated(unsafe) var loadUserProfileUnderlyingReturnValue: Result<Void, ClientProxyError>!
var loadUserProfileReturnValue: Result<Void, ClientProxyError>! {
get { loadUserProfileReturnValueLock.withLock { loadUserProfileUnderlyingReturnValue } }
set { loadUserProfileReturnValueLock.withLock { loadUserProfileUnderlyingReturnValue = newValue } }
}
nonisolated(unsafe) var loadUserDisplayNameClosure: (() async -> Result<Void, ClientProxyError>)?
nonisolated(unsafe) var loadUserProfileClosure: (() async -> Result<Void, ClientProxyError>)?
@discardableResult
@concurrent func loadUserDisplayName() async -> Result<Void, ClientProxyError> {
loadUserDisplayNameCallsCountLock.withLock { loadUserDisplayNameUnderlyingCallsCount += 1 }
if let loadUserDisplayNameClosure = loadUserDisplayNameClosure {
return await loadUserDisplayNameClosure()
@concurrent func loadUserProfile() async -> Result<Void, ClientProxyError> {
loadUserProfileCallsCountLock.withLock { loadUserProfileUnderlyingCallsCount += 1 }
if let loadUserProfileClosure = loadUserProfileClosure {
return await loadUserProfileClosure()
} else {
return loadUserDisplayNameReturnValue
return loadUserProfileReturnValue
}
}
//MARK: - setUserDisplayName
@@ -3245,35 +3240,6 @@ nonisolated class ClientProxyMock: ClientProxyProtocol, @unchecked Sendable {
return setUserDisplayNameReturnValue
}
}
//MARK: - loadUserAvatarURL
private let loadUserAvatarURLCallsCountLock = NSLock()
private nonisolated(unsafe) var loadUserAvatarURLUnderlyingCallsCount = 0
var loadUserAvatarURLCallsCount: Int {
get { loadUserAvatarURLCallsCountLock.withLock { loadUserAvatarURLUnderlyingCallsCount } }
set { loadUserAvatarURLCallsCountLock.withLock { loadUserAvatarURLUnderlyingCallsCount = newValue } }
}
var loadUserAvatarURLCalled: Bool {
return loadUserAvatarURLCallsCount > 0
}
private let loadUserAvatarURLReturnValueLock = NSLock()
private nonisolated(unsafe) var loadUserAvatarURLUnderlyingReturnValue: Result<Void, ClientProxyError>!
var loadUserAvatarURLReturnValue: Result<Void, ClientProxyError>! {
get { loadUserAvatarURLReturnValueLock.withLock { loadUserAvatarURLUnderlyingReturnValue } }
set { loadUserAvatarURLReturnValueLock.withLock { loadUserAvatarURLUnderlyingReturnValue = newValue } }
}
nonisolated(unsafe) var loadUserAvatarURLClosure: (() async -> Result<Void, ClientProxyError>)?
@discardableResult
@concurrent func loadUserAvatarURL() async -> Result<Void, ClientProxyError> {
loadUserAvatarURLCallsCountLock.withLock { loadUserAvatarURLUnderlyingCallsCount += 1 }
if let loadUserAvatarURLClosure = loadUserAvatarURLClosure {
return await loadUserAvatarURLClosure()
} else {
return loadUserAvatarURLReturnValue
}
}
//MARK: - setUserAvatar
private let setUserAvatarMediaCallsCountLock = NSLock()