mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 06:55:59 +00:00
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:
@@ -0,0 +1,43 @@
|
||||
//
|
||||
// Copyright 2026 Element Creations Ltd.
|
||||
//
|
||||
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial.
|
||||
// Please see LICENSE files in the repository root for full details.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import MatrixRustSDK
|
||||
|
||||
struct HomeserverCapabilitiesProxy: HomeserverCapabilitiesProxyProtocol {
|
||||
private let underlyingCapabilities: HomeserverCapabilitiesProtocol
|
||||
|
||||
init(underlyingCapabilities: HomeserverCapabilitiesProtocol) {
|
||||
self.underlyingCapabilities = underlyingCapabilities
|
||||
}
|
||||
|
||||
func refresh() async {
|
||||
do {
|
||||
try await underlyingCapabilities.refresh()
|
||||
} catch {
|
||||
MXLog.error("Failure refreshing homeserver capabilities: \(error)")
|
||||
}
|
||||
}
|
||||
|
||||
func canChangeAvatar() async -> Bool {
|
||||
do {
|
||||
return try await underlyingCapabilities.canChangeAvatar()
|
||||
} catch {
|
||||
MXLog.error("Failure checking canChangeAvatar: \(error)")
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
func canChangeDisplayName() async -> Bool {
|
||||
do {
|
||||
return try await underlyingCapabilities.canChangeDisplayname()
|
||||
} catch {
|
||||
MXLog.error("Failure checking canChangeDisplayName: \(error)")
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
//
|
||||
// Copyright 2026 Element Creations Ltd.
|
||||
//
|
||||
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial.
|
||||
// Please see LICENSE files in the repository root for full details.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
// sourcery: AutoMockable
|
||||
protocol HomeserverCapabilitiesProxyProtocol {
|
||||
func refresh() async
|
||||
func canChangeAvatar() async -> Bool
|
||||
func canChangeDisplayName() async -> Bool
|
||||
}
|
||||
@@ -64,6 +64,9 @@ class ClientProxy: ClientProxyProtocol {
|
||||
|
||||
let spaceService: SpaceServiceProxyProtocol
|
||||
|
||||
let capabilities: HomeserverCapabilitiesProxyProtocol
|
||||
private var capabilitiesRefreshTask: Task<Void, Never>?
|
||||
|
||||
let eventStringBuilder: RoomEventStringBuilder
|
||||
|
||||
private static var roomCreationPowerLevelOverrides: PowerLevels {
|
||||
@@ -208,6 +211,8 @@ class ClientProxy: ClientProxyProtocol {
|
||||
|
||||
spaceService = await SpaceServiceProxy(spaceService: client.spaceService())
|
||||
|
||||
capabilities = HomeserverCapabilitiesProxy(underlyingCapabilities: client.homeserverCapabilities())
|
||||
|
||||
let configuredAppService = try await ClientProxyServices(client: client,
|
||||
actionsSubject: actionsSubject,
|
||||
notificationSettings: notificationSettings,
|
||||
@@ -1122,17 +1127,25 @@ class ClientProxy: ClientProxyProtocol {
|
||||
|
||||
MXLog.info("Received room list update: \(state)")
|
||||
|
||||
guard state != .error,
|
||||
state != .terminated else {
|
||||
// The sync service is responsible of handling error and termination
|
||||
return
|
||||
}
|
||||
|
||||
// Hide the sync spinner as soon as we get any update back
|
||||
actionsSubject.send(.receivedSyncUpdate)
|
||||
|
||||
if ignoredUsersSubject.value == nil {
|
||||
updateIgnoredUsers()
|
||||
switch state {
|
||||
case .initial, .settingUp, .recovering:
|
||||
break // Don't do anything until we're actually running.
|
||||
case .running:
|
||||
// Hide the sync spinner as soon as we get any update back
|
||||
actionsSubject.send(.receivedSyncUpdate)
|
||||
|
||||
if ignoredUsersSubject.value == nil {
|
||||
updateIgnoredUsers()
|
||||
}
|
||||
|
||||
if capabilitiesRefreshTask == nil {
|
||||
capabilitiesRefreshTask = Task { [weak self] in
|
||||
await self?.capabilities.refresh()
|
||||
self?.capabilitiesRefreshTask = nil
|
||||
}
|
||||
}
|
||||
case .error, .terminated:
|
||||
break // The sync service is responsible for handling error and termination
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -145,6 +145,8 @@ protocol ClientProxyProtocol: AnyObject {
|
||||
|
||||
var spaceService: SpaceServiceProxyProtocol { get }
|
||||
|
||||
var capabilities: HomeserverCapabilitiesProxyProtocol { get }
|
||||
|
||||
var isReportRoomSupported: Bool { get async }
|
||||
|
||||
var isLiveKitRTCSupported: Bool { get async }
|
||||
|
||||
Reference in New Issue
Block a user