Add support for homeserver capabilities to disable the UserDetailsEditScreen UI. (#5421)

Add support for homeserver capabilities to disable editing your user profile.

Also updates editable avatar size/formatting to match the latest Figma at the same time.
This commit is contained in:
Doug
2026-04-17 11:52:46 +01:00
committed by GitHub
parent c40454bbd3
commit eef4a2497a
46 changed files with 482 additions and 142 deletions
@@ -29,6 +29,9 @@ struct ClientProxyMockConfiguration {
var timelineMediaVisibility = TimelineMediaVisibility.always
var hideInviteAvatars = false
var canChangeAvatar = true
var canChangeDisplayName = true
var maxMediaUploadSize: UInt = 100 * 1024 * 1024
class Overrides {
@@ -109,6 +112,11 @@ extension ClientProxyMock {
spaceService = SpaceServiceProxyMock(configuration.spaceServiceConfiguration)
linkNewDeviceServiceReturnValue = LinkNewDeviceServiceMock(.init())
let capabilities = HomeserverCapabilitiesProxyMock()
capabilities.canChangeAvatarReturnValue = configuration.canChangeAvatar
capabilities.canChangeDisplayNameReturnValue = configuration.canChangeDisplayName
self.capabilities = capabilities
roomForIdentifierClosure = { [weak self] identifier in
if let room = self?.roomSummaryProvider.roomListPublisher.value.first(where: { $0.id == identifier }) {
let joinedRoomIDs = configuration.overrides.joinedRoomIDs
@@ -2696,6 +2696,11 @@ class ClientProxyMock: ClientProxyProtocol, @unchecked Sendable {
set(value) { underlyingSpaceService = value }
}
var underlyingSpaceService: SpaceServiceProxyProtocol!
var capabilities: HomeserverCapabilitiesProxyProtocol {
get { return underlyingCapabilities }
set(value) { underlyingCapabilities = value }
}
var underlyingCapabilities: HomeserverCapabilitiesProxyProtocol!
var isReportRoomSupportedCallsCount = 0
var isReportRoomSupportedCalled: Bool {
return isReportRoomSupportedCallsCount > 0
@@ -6945,6 +6950,172 @@ class ElementCallWidgetDriverMock: ElementCallWidgetDriverProtocol, @unchecked S
}
}
}
class HomeserverCapabilitiesProxyMock: HomeserverCapabilitiesProxyProtocol, @unchecked Sendable {
//MARK: - refresh
var refreshUnderlyingCallsCount = 0
var refreshCallsCount: Int {
get {
if Thread.isMainThread {
return refreshUnderlyingCallsCount
} else {
var returnValue: Int? = nil
DispatchQueue.main.sync {
returnValue = refreshUnderlyingCallsCount
}
return returnValue!
}
}
set {
if Thread.isMainThread {
refreshUnderlyingCallsCount = newValue
} else {
DispatchQueue.main.sync {
refreshUnderlyingCallsCount = newValue
}
}
}
}
var refreshCalled: Bool {
return refreshCallsCount > 0
}
var refreshClosure: (() async -> Void)?
func refresh() async {
refreshCallsCount += 1
await refreshClosure?()
}
//MARK: - canChangeAvatar
var canChangeAvatarUnderlyingCallsCount = 0
var canChangeAvatarCallsCount: Int {
get {
if Thread.isMainThread {
return canChangeAvatarUnderlyingCallsCount
} else {
var returnValue: Int? = nil
DispatchQueue.main.sync {
returnValue = canChangeAvatarUnderlyingCallsCount
}
return returnValue!
}
}
set {
if Thread.isMainThread {
canChangeAvatarUnderlyingCallsCount = newValue
} else {
DispatchQueue.main.sync {
canChangeAvatarUnderlyingCallsCount = newValue
}
}
}
}
var canChangeAvatarCalled: Bool {
return canChangeAvatarCallsCount > 0
}
var canChangeAvatarUnderlyingReturnValue: Bool!
var canChangeAvatarReturnValue: Bool! {
get {
if Thread.isMainThread {
return canChangeAvatarUnderlyingReturnValue
} else {
var returnValue: Bool? = nil
DispatchQueue.main.sync {
returnValue = canChangeAvatarUnderlyingReturnValue
}
return returnValue!
}
}
set {
if Thread.isMainThread {
canChangeAvatarUnderlyingReturnValue = newValue
} else {
DispatchQueue.main.sync {
canChangeAvatarUnderlyingReturnValue = newValue
}
}
}
}
var canChangeAvatarClosure: (() async -> Bool)?
func canChangeAvatar() async -> Bool {
canChangeAvatarCallsCount += 1
if let canChangeAvatarClosure = canChangeAvatarClosure {
return await canChangeAvatarClosure()
} else {
return canChangeAvatarReturnValue
}
}
//MARK: - canChangeDisplayName
var canChangeDisplayNameUnderlyingCallsCount = 0
var canChangeDisplayNameCallsCount: Int {
get {
if Thread.isMainThread {
return canChangeDisplayNameUnderlyingCallsCount
} else {
var returnValue: Int? = nil
DispatchQueue.main.sync {
returnValue = canChangeDisplayNameUnderlyingCallsCount
}
return returnValue!
}
}
set {
if Thread.isMainThread {
canChangeDisplayNameUnderlyingCallsCount = newValue
} else {
DispatchQueue.main.sync {
canChangeDisplayNameUnderlyingCallsCount = newValue
}
}
}
}
var canChangeDisplayNameCalled: Bool {
return canChangeDisplayNameCallsCount > 0
}
var canChangeDisplayNameUnderlyingReturnValue: Bool!
var canChangeDisplayNameReturnValue: Bool! {
get {
if Thread.isMainThread {
return canChangeDisplayNameUnderlyingReturnValue
} else {
var returnValue: Bool? = nil
DispatchQueue.main.sync {
returnValue = canChangeDisplayNameUnderlyingReturnValue
}
return returnValue!
}
}
set {
if Thread.isMainThread {
canChangeDisplayNameUnderlyingReturnValue = newValue
} else {
DispatchQueue.main.sync {
canChangeDisplayNameUnderlyingReturnValue = newValue
}
}
}
}
var canChangeDisplayNameClosure: (() async -> Bool)?
func canChangeDisplayName() async -> Bool {
canChangeDisplayNameCallsCount += 1
if let canChangeDisplayNameClosure = canChangeDisplayNameClosure {
return await canChangeDisplayNameClosure()
} else {
return canChangeDisplayNameReturnValue
}
}
}
class InvitedRoomProxyMock: InvitedRoomProxyProtocol, @unchecked Sendable {
var info: BaseRoomInfoProxyProtocol {
get { return underlyingInfo }