Update the SDK and handle API breaks. (#5871)

* Update the SDK and handle API breaks.

* Rename sdkUserThing to rustUserThing for consistency.

* Add user status ClientProxy methods.

* Rename UserStatus.UserSet to UserStatus.Raw.
This commit is contained in:
Doug
2026-07-14 16:35:37 +01:00
committed by GitHub
parent f776ea7133
commit 85f28d017d
17 changed files with 278 additions and 54 deletions
@@ -710,9 +710,7 @@ class ClientProxy: ClientProxyProtocol {
func setUserDisplayName(_ name: String) async -> Result<Void, ClientProxyError> {
do {
try await client.setDisplayName(name: name)
Task {
await self.loadUserProfile()
}
Task { await self.loadUserProfile() }
return .success(())
} catch {
MXLog.error("Failed setting user display name with error: \(error)")
@@ -729,9 +727,7 @@ class ClientProxy: ClientProxyProtocol {
do {
let data = try Data(contentsOf: imageURL)
try await client.uploadAvatar(mimeType: mimeType, data: data)
Task {
await self.loadUserProfile()
}
Task { await self.loadUserProfile() }
return .success(())
} catch {
MXLog.error("Failed setting user avatar with error: \(error)")
@@ -742,9 +738,7 @@ class ClientProxy: ClientProxyProtocol {
func removeUserAvatar() async -> Result<Void, ClientProxyError> {
do {
try await client.removeAvatar()
Task {
await self.loadUserProfile()
}
Task { await self.loadUserProfile() }
return .success(())
} catch {
MXLog.error("Failed removing user avatar with error: \(error)")
@@ -752,6 +746,28 @@ class ClientProxy: ClientProxyProtocol {
}
}
func setUserStatus(_ status: UserStatus.Raw) async -> Result<Void, ClientProxyError> {
do {
try await client.setUserStatus(status: status.rustValue)
Task { await self.loadUserProfile() }
return .success(())
} catch {
MXLog.error("Failed setting user status with error: \(error)")
return .failure(.sdkError(error))
}
}
func removeUserStatus() async -> Result<Void, ClientProxyError> {
do {
try await client.clearUserStatus()
Task { await self.loadUserProfile() }
return .success(())
} catch {
MXLog.error("Failed removing user status with error: \(error)")
return .failure(.sdkError(error))
}
}
func linkNewDeviceService() -> LinkNewDeviceServiceProtocol {
LinkNewDeviceService(handler: client.newGrantLoginWithQrCodeHandler())
}
@@ -786,7 +802,7 @@ class ClientProxy: ClientProxyProtocol {
func searchUsers(searchTerm: String, limit: UInt) async -> Result<SearchUsersResults, ClientProxyError> {
do {
return try await .success(.init(sdkResults: client.searchUsers(searchTerm: searchTerm, limit: UInt64(limit))))
return try await .success(.init(rustResults: client.searchUsers(searchTerm: searchTerm, limit: UInt64(limit))))
} catch {
MXLog.error("Failed searching users with error: \(error)")
return .failure(.sdkError(error))
@@ -795,7 +811,7 @@ class ClientProxy: ClientProxyProtocol {
func profile(for userID: String) async -> Result<UserProfile, ClientProxyError> {
do {
return try await .success(.init(sdkUserProfile: client.getProfile(userId: userID)))
return try await .success(.init(rustUserProfile: client.getProfile(userId: userID)))
} catch {
MXLog.error("Failed retrieving profile for userID: \(userID) with error: \(error)")
return .failure(.sdkError(error))