mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 21:33:26 +00:00
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:
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user