mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-04 01:20:12 +00:00
Update the SDK and handle some API breaks. (#5986)
This commit is contained in:
@@ -3305,60 +3305,32 @@ nonisolated class ClientProxyMock: ClientProxyProtocol, @unchecked Sendable {
|
||||
return setUserStatusReturnValue
|
||||
}
|
||||
}
|
||||
//MARK: - removeUserStatus
|
||||
//MARK: - clearUserStatus
|
||||
|
||||
private let removeUserStatusCallsCountLock = NSLock()
|
||||
private nonisolated(unsafe) var removeUserStatusUnderlyingCallsCount = 0
|
||||
var removeUserStatusCallsCount: Int {
|
||||
get { removeUserStatusCallsCountLock.withLock { removeUserStatusUnderlyingCallsCount } }
|
||||
set { removeUserStatusCallsCountLock.withLock { removeUserStatusUnderlyingCallsCount = newValue } }
|
||||
private let clearUserStatusCallsCountLock = NSLock()
|
||||
private nonisolated(unsafe) var clearUserStatusUnderlyingCallsCount = 0
|
||||
var clearUserStatusCallsCount: Int {
|
||||
get { clearUserStatusCallsCountLock.withLock { clearUserStatusUnderlyingCallsCount } }
|
||||
set { clearUserStatusCallsCountLock.withLock { clearUserStatusUnderlyingCallsCount = newValue } }
|
||||
}
|
||||
var removeUserStatusCalled: Bool {
|
||||
return removeUserStatusCallsCount > 0
|
||||
var clearUserStatusCalled: Bool {
|
||||
return clearUserStatusCallsCount > 0
|
||||
}
|
||||
|
||||
private let removeUserStatusReturnValueLock = NSLock()
|
||||
private nonisolated(unsafe) var removeUserStatusUnderlyingReturnValue: Result<Void, ClientProxyError>!
|
||||
var removeUserStatusReturnValue: Result<Void, ClientProxyError>! {
|
||||
get { removeUserStatusReturnValueLock.withLock { removeUserStatusUnderlyingReturnValue } }
|
||||
set { removeUserStatusReturnValueLock.withLock { removeUserStatusUnderlyingReturnValue = newValue } }
|
||||
private let clearUserStatusReturnValueLock = NSLock()
|
||||
private nonisolated(unsafe) var clearUserStatusUnderlyingReturnValue: Result<Void, ClientProxyError>!
|
||||
var clearUserStatusReturnValue: Result<Void, ClientProxyError>! {
|
||||
get { clearUserStatusReturnValueLock.withLock { clearUserStatusUnderlyingReturnValue } }
|
||||
set { clearUserStatusReturnValueLock.withLock { clearUserStatusUnderlyingReturnValue = newValue } }
|
||||
}
|
||||
nonisolated(unsafe) var removeUserStatusClosure: (() async -> Result<Void, ClientProxyError>)?
|
||||
nonisolated(unsafe) var clearUserStatusClosure: (() async -> Result<Void, ClientProxyError>)?
|
||||
|
||||
@concurrent func removeUserStatus() async -> Result<Void, ClientProxyError> {
|
||||
removeUserStatusCallsCountLock.withLock { removeUserStatusUnderlyingCallsCount += 1 }
|
||||
if let removeUserStatusClosure = removeUserStatusClosure {
|
||||
return await removeUserStatusClosure()
|
||||
@concurrent func clearUserStatus() async -> Result<Void, ClientProxyError> {
|
||||
clearUserStatusCallsCountLock.withLock { clearUserStatusUnderlyingCallsCount += 1 }
|
||||
if let clearUserStatusClosure = clearUserStatusClosure {
|
||||
return await clearUserStatusClosure()
|
||||
} else {
|
||||
return removeUserStatusReturnValue
|
||||
}
|
||||
}
|
||||
//MARK: - removeCallStatus
|
||||
|
||||
private let removeCallStatusCallsCountLock = NSLock()
|
||||
private nonisolated(unsafe) var removeCallStatusUnderlyingCallsCount = 0
|
||||
var removeCallStatusCallsCount: Int {
|
||||
get { removeCallStatusCallsCountLock.withLock { removeCallStatusUnderlyingCallsCount } }
|
||||
set { removeCallStatusCallsCountLock.withLock { removeCallStatusUnderlyingCallsCount = newValue } }
|
||||
}
|
||||
var removeCallStatusCalled: Bool {
|
||||
return removeCallStatusCallsCount > 0
|
||||
}
|
||||
|
||||
private let removeCallStatusReturnValueLock = NSLock()
|
||||
private nonisolated(unsafe) var removeCallStatusUnderlyingReturnValue: Result<Void, ClientProxyError>!
|
||||
var removeCallStatusReturnValue: Result<Void, ClientProxyError>! {
|
||||
get { removeCallStatusReturnValueLock.withLock { removeCallStatusUnderlyingReturnValue } }
|
||||
set { removeCallStatusReturnValueLock.withLock { removeCallStatusUnderlyingReturnValue = newValue } }
|
||||
}
|
||||
nonisolated(unsafe) var removeCallStatusClosure: (() async -> Result<Void, ClientProxyError>)?
|
||||
|
||||
@concurrent func removeCallStatus() async -> Result<Void, ClientProxyError> {
|
||||
removeCallStatusCallsCountLock.withLock { removeCallStatusUnderlyingCallsCount += 1 }
|
||||
if let removeCallStatusClosure = removeCallStatusClosure {
|
||||
return await removeCallStatusClosure()
|
||||
} else {
|
||||
return removeCallStatusReturnValue
|
||||
return clearUserStatusReturnValue
|
||||
}
|
||||
}
|
||||
//MARK: - linkNewDeviceService
|
||||
|
||||
@@ -10,7 +10,7 @@ import Foundation
|
||||
import MatrixRustSDK
|
||||
|
||||
nonisolated enum TraceLogPack: Codable, CaseIterable {
|
||||
case eventCache, sendQueue, timeline, notificationClient, syncProfiling, latestEvents
|
||||
case eventCache, sendQueue, timeline, notificationClient, syncProfiling, latestEvents, search
|
||||
|
||||
var title: String {
|
||||
switch self {
|
||||
@@ -20,6 +20,7 @@ nonisolated enum TraceLogPack: Codable, CaseIterable {
|
||||
case .notificationClient: "Notification client"
|
||||
case .syncProfiling: "Sync profiling"
|
||||
case .latestEvents: "Latest events"
|
||||
case .search: "Search"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -27,13 +28,14 @@ nonisolated enum TraceLogPack: Codable, CaseIterable {
|
||||
nonisolated extension TraceLogPack {
|
||||
// periphery:ignore - Unused, but added to detect new cases when updating the SDK.
|
||||
init(rustLogPack: MatrixRustSDK.TraceLogPacks) {
|
||||
switch rustLogPack {
|
||||
case .eventCache: self = .eventCache
|
||||
case .sendQueue: self = .sendQueue
|
||||
case .timeline: self = .timeline
|
||||
case .notificationClient: self = .notificationClient
|
||||
case .syncProfiling: self = .syncProfiling
|
||||
case .latestEvents: self = .latestEvents
|
||||
self = switch rustLogPack {
|
||||
case .eventCache: .eventCache
|
||||
case .sendQueue: .sendQueue
|
||||
case .timeline: .timeline
|
||||
case .notificationClient: .notificationClient
|
||||
case .syncProfiling: .syncProfiling
|
||||
case .latestEvents: .latestEvents
|
||||
case .search: .search
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,6 +47,7 @@ nonisolated extension TraceLogPack {
|
||||
case .notificationClient: .notificationClient
|
||||
case .syncProfiling: .syncProfiling
|
||||
case .latestEvents: .latestEvents
|
||||
case .search: .search
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,7 +109,7 @@ enum SettingsScreenViewAction {
|
||||
/// Set the user's status to the provided value.
|
||||
case set(UserStatus.Raw)
|
||||
/// Clears the user's currently displayed status.
|
||||
case clear(UserStatus.Displayed)
|
||||
case clear
|
||||
/// Cancel user status picking/input.
|
||||
case cancel
|
||||
}
|
||||
|
||||
@@ -108,8 +108,8 @@ class SettingsScreenViewModel: SettingsScreenViewModelType, SettingsScreenViewMo
|
||||
pickCustomEmoji()
|
||||
case .userStatus(.set(let status)):
|
||||
Task { await setUserStatus(status) }
|
||||
case .userStatus(.clear(let status)):
|
||||
Task { await clearUserStatus(status) }
|
||||
case .userStatus(.clear):
|
||||
Task { await clearUserStatus() }
|
||||
case .userStatus(.cancel):
|
||||
state.bindings.isPresentingStatusPicker = false
|
||||
state.bindings.isShowingCustomStatusField = false
|
||||
@@ -161,7 +161,7 @@ class SettingsScreenViewModel: SettingsScreenViewModelType, SettingsScreenViewMo
|
||||
.asCancellable()
|
||||
}
|
||||
|
||||
func setUserStatus(_ status: UserStatus.Raw) async {
|
||||
private func setUserStatus(_ status: UserStatus.Raw) async {
|
||||
// Loading state tbc
|
||||
state.bindings.isPresentingStatusPicker = false
|
||||
state.bindings.isShowingCustomStatusField = false
|
||||
@@ -177,19 +177,13 @@ class SettingsScreenViewModel: SettingsScreenViewModelType, SettingsScreenViewMo
|
||||
}
|
||||
}
|
||||
|
||||
func clearUserStatus(_ status: UserStatus.Displayed) async {
|
||||
/// Clears both the `UserStatus.Raw` and `UserStatus.Call` values simultaneously.
|
||||
private func clearUserStatus() async {
|
||||
// Loading state tbc
|
||||
state.bindings.isPresentingStatusPicker = false
|
||||
state.bindings.isShowingCustomStatusField = false
|
||||
|
||||
let result = switch status {
|
||||
case .userSet:
|
||||
await clientProxy.removeUserStatus()
|
||||
case .inCall:
|
||||
await clientProxy.removeCallStatus()
|
||||
}
|
||||
|
||||
switch result {
|
||||
switch await clientProxy.clearUserStatus() {
|
||||
case .success:
|
||||
break // Loading/error state tbc
|
||||
case .failure:
|
||||
|
||||
+1
-1
@@ -71,7 +71,7 @@ struct SettingsScreenUserStatusRow: View {
|
||||
.accessibilityValue(Text(String(status.emoji)) + Text(status.text))
|
||||
.buttonStyle(.plain)
|
||||
|
||||
Button(L10n.actionClear) { action(.clear(status)) }
|
||||
Button(L10n.actionClear) { action(.clear) }
|
||||
.buttonStyle(.compound(.textLink))
|
||||
}
|
||||
.padding(ListRowPadding.insets)
|
||||
|
||||
@@ -777,7 +777,7 @@ class ClientProxy: ClientProxyProtocol {
|
||||
}
|
||||
}
|
||||
|
||||
func removeUserStatus() async -> Result<Void, ClientProxyError> {
|
||||
func clearUserStatus() async -> Result<Void, ClientProxyError> {
|
||||
do {
|
||||
try await client.clearUserStatus()
|
||||
// No need to refresh the profile, we only support user status with the profiles /sync extension.
|
||||
@@ -788,17 +788,6 @@ class ClientProxy: ClientProxyProtocol {
|
||||
}
|
||||
}
|
||||
|
||||
func removeCallStatus() async -> Result<Void, ClientProxyError> {
|
||||
do {
|
||||
try await client.clearCallStatus()
|
||||
// No need to refresh the profile, we only support user status with the profiles /sync extension.
|
||||
return .success(())
|
||||
} catch {
|
||||
MXLog.error("Failed removing call status with error: \(error)")
|
||||
return .failure(.sdkError(error))
|
||||
}
|
||||
}
|
||||
|
||||
func linkNewDeviceService() -> LinkNewDeviceServiceProtocol {
|
||||
LinkNewDeviceService(handler: client.newGrantLoginWithQrCodeHandler())
|
||||
}
|
||||
|
||||
@@ -229,8 +229,8 @@ protocol ClientProxyProtocol: AnyObject {
|
||||
func removeUserAvatar() async -> Result<Void, ClientProxyError>
|
||||
func isUserStatusSupported() async -> Result<Bool, ClientProxyError>
|
||||
func setUserStatus(_ status: UserStatus.Raw) async -> Result<Void, ClientProxyError>
|
||||
func removeUserStatus() async -> Result<Void, ClientProxyError>
|
||||
func removeCallStatus() async -> Result<Void, ClientProxyError>
|
||||
/// Removes both the `m.status` and `m.call` fields from the user's profile.
|
||||
func clearUserStatus() async -> Result<Void, ClientProxyError>
|
||||
|
||||
func linkNewDeviceService() -> LinkNewDeviceServiceProtocol
|
||||
|
||||
|
||||
Reference in New Issue
Block a user