mirror of
https://github.com/element-hq/element-x-ios.git
synced 2025-03-10 21:39:12 +00:00
Bump SDK to v1.0.107-alpha. Simplify syncService state handling
This commit is contained in:
parent
8d409e7817
commit
5400910855
@ -5451,7 +5451,7 @@
|
||||
repositoryURL = "https://github.com/matrix-org/matrix-rust-components-swift";
|
||||
requirement = {
|
||||
kind = exactVersion;
|
||||
version = "1.0.106-alpha";
|
||||
version = "1.0.107-alpha";
|
||||
};
|
||||
};
|
||||
821C67C9A7F8CC3FD41B28B4 /* XCRemoteSwiftPackageReference "emojibase-bindings" */ = {
|
||||
|
@ -129,8 +129,8 @@
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/matrix-org/matrix-rust-components-swift",
|
||||
"state" : {
|
||||
"revision" : "e9c185dc6a9d01c198fae36161b0e4180dfcfdd6",
|
||||
"version" : "1.0.106-alpha"
|
||||
"revision" : "28211915a5a5ca926798d12bedc3bf1a352714fd",
|
||||
"version" : "1.0.107-alpha"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -538,7 +538,7 @@ class AppCoordinator: AppCoordinatorProtocol, AuthenticationCoordinatorDelegate,
|
||||
// MARK: - Application State
|
||||
|
||||
private func stopSync() {
|
||||
userSession?.clientProxy.pauseSync()
|
||||
userSession?.clientProxy.stopSync()
|
||||
clientProxyObserver = nil
|
||||
}
|
||||
|
||||
@ -595,7 +595,7 @@ class AppCoordinator: AppCoordinatorProtocol, AuthenticationCoordinatorDelegate,
|
||||
|
||||
@objc
|
||||
private func applicationWillTerminate() {
|
||||
userSession?.clientProxy.pauseSync()
|
||||
userSession?.clientProxy.stopSync()
|
||||
}
|
||||
|
||||
@objc
|
||||
@ -609,7 +609,7 @@ class AppCoordinator: AppCoordinatorProtocol, AuthenticationCoordinatorDelegate,
|
||||
backgroundTask = backgroundTaskService.startBackgroundTask(withName: "SuspendApp: \(UUID().uuidString)") { [weak self] in
|
||||
guard let self else { return }
|
||||
|
||||
userSession?.clientProxy.pauseSync()
|
||||
userSession?.clientProxy.stopSync()
|
||||
|
||||
backgroundTask?.stop()
|
||||
backgroundTask = nil
|
||||
@ -629,7 +629,7 @@ class AppCoordinator: AppCoordinatorProtocol, AuthenticationCoordinatorDelegate,
|
||||
backgroundTask?.stop()
|
||||
backgroundTask = nil
|
||||
|
||||
if isSuspended, userSession?.clientProxy.isSyncing == false {
|
||||
if isSuspended {
|
||||
startSync()
|
||||
}
|
||||
|
||||
@ -681,9 +681,7 @@ class AppCoordinator: AppCoordinatorProtocol, AuthenticationCoordinatorDelegate,
|
||||
return
|
||||
}
|
||||
|
||||
if !userSession.clientProxy.isSyncing {
|
||||
startSync()
|
||||
}
|
||||
startSync()
|
||||
|
||||
// Be a good citizen, run for a max of 10 SS responses or 10 seconds
|
||||
// An SS request will time out after 30 seconds if no new data is available
|
||||
|
@ -75,7 +75,7 @@ enum MXLog {
|
||||
self.target = Constants.target
|
||||
}
|
||||
|
||||
rootSpan = Span(file: #file, line: #line, column: #column, level: .info, target: self.target, name: "root")
|
||||
rootSpan = Span(file: #file, line: #line, level: .info, target: self.target, name: "root")
|
||||
|
||||
rootSpan.enter()
|
||||
|
||||
@ -181,7 +181,7 @@ enum MXLog {
|
||||
rootSpan.enter()
|
||||
}
|
||||
|
||||
return Span(file: file, line: UInt32(line), column: UInt32(column), level: level, target: target, name: name)
|
||||
return Span(file: file, line: UInt32(line), level: level, target: target, name: name)
|
||||
}
|
||||
|
||||
private static func log(_ message: Any,
|
||||
@ -199,6 +199,6 @@ enum MXLog {
|
||||
rootSpan.enter()
|
||||
}
|
||||
|
||||
logEvent(file: (file as NSString).lastPathComponent, line: UInt32(line), column: UInt32(column), level: level, target: target, message: "\(message)")
|
||||
logEvent(file: (file as NSString).lastPathComponent, line: UInt32(line), level: level, target: target, message: "\(message)")
|
||||
}
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ class ClientProxy: ClientProxyProtocol {
|
||||
|
||||
deinit {
|
||||
client.setDelegate(delegate: nil)
|
||||
pauseSync()
|
||||
stopSync()
|
||||
}
|
||||
|
||||
let callbacks = PassthroughSubject<ClientProxyCallback, Never>()
|
||||
@ -109,37 +109,23 @@ class ClientProxy: ClientProxyProtocol {
|
||||
}
|
||||
}
|
||||
|
||||
var isSyncing: Bool {
|
||||
isStartingSync || syncService?.currentState() == .running
|
||||
}
|
||||
|
||||
/// Ensure we don't call start sync whilst awaiting a previous call.
|
||||
private var isStartingSync = false
|
||||
|
||||
func startSync() {
|
||||
guard !isSyncing else { return }
|
||||
|
||||
MXLog.info("Starting sync")
|
||||
isStartingSync = true
|
||||
|
||||
Task {
|
||||
do {
|
||||
try await syncService?.start()
|
||||
} catch {
|
||||
MXLog.error("Failed starting app service with error: \(error)")
|
||||
}
|
||||
|
||||
isStartingSync = false
|
||||
await syncService?.start()
|
||||
}
|
||||
}
|
||||
|
||||
func pauseSync() {
|
||||
func stopSync() {
|
||||
MXLog.info("Stopping sync")
|
||||
|
||||
do {
|
||||
try syncService?.pause()
|
||||
} catch {
|
||||
MXLog.error("Failed pausing app service with error: \(error)")
|
||||
Task {
|
||||
do {
|
||||
try await syncService?.stop()
|
||||
} catch {
|
||||
MXLog.error("Failed stopping the sync service with error: \(error)")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -367,19 +353,17 @@ class ClientProxy: ClientProxyProtocol {
|
||||
// MARK: Private
|
||||
|
||||
private func restartSync(delay: Duration = .zero) {
|
||||
isStartingSync = true
|
||||
|
||||
Task {
|
||||
try await Task.sleep(for: delay)
|
||||
|
||||
do {
|
||||
MXLog.info("Restart the app service.")
|
||||
try await self.syncService?.start()
|
||||
MXLog.info("Restarting the sync service.")
|
||||
try await self.syncService?.stop()
|
||||
} catch {
|
||||
MXLog.error("Failed restarting app service after error.")
|
||||
MXLog.error("Failed restarting the sync service with error: \(error)")
|
||||
}
|
||||
|
||||
self.isStartingSync = false
|
||||
await self.syncService?.start()
|
||||
}
|
||||
}
|
||||
|
||||
@ -437,7 +421,7 @@ class ClientProxy: ClientProxyProtocol {
|
||||
syncService.state(listener: SyncServiceStateObserverProxy { [weak self] state in
|
||||
guard let self else { return }
|
||||
|
||||
MXLog.info("Received app service update: \(state)")
|
||||
MXLog.info("Received sync service update: \(state)")
|
||||
|
||||
switch state {
|
||||
case .running, .terminated, .idle:
|
||||
@ -454,7 +438,7 @@ class ClientProxy: ClientProxyProtocol {
|
||||
guard let self,
|
||||
state != .error,
|
||||
state != .terminated else {
|
||||
// The app service is responsible of handling error and termination
|
||||
// The sync service is responsible of handling error and termination
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -80,11 +80,9 @@ protocol ClientProxyProtocol: AnyObject, MediaLoaderProtocol {
|
||||
|
||||
var inviteSummaryProvider: RoomSummaryProviderProtocol? { get }
|
||||
|
||||
var isSyncing: Bool { get }
|
||||
|
||||
func startSync()
|
||||
|
||||
func pauseSync()
|
||||
func stopSync()
|
||||
|
||||
func directRoomForUserID(_ userID: String) async -> Result<String?, ClientProxyError>
|
||||
|
||||
|
@ -32,8 +32,6 @@ class MockClientProxy: ClientProxyProtocol {
|
||||
|
||||
var avatarURLPublisher: AnyPublisher<URL?, Never> { Empty().eraseToAnyPublisher() }
|
||||
|
||||
var isSyncing: Bool { false }
|
||||
|
||||
init(userID: String, deviceID: String? = nil, roomSummaryProvider: RoomSummaryProviderProtocol? = MockRoomSummaryProvider()) {
|
||||
self.userID = userID
|
||||
self.deviceID = deviceID
|
||||
@ -46,7 +44,7 @@ class MockClientProxy: ClientProxyProtocol {
|
||||
|
||||
func stopSync(completionHandler: () -> Void) { }
|
||||
|
||||
func pauseSync() { }
|
||||
func stopSync() { }
|
||||
|
||||
func directRoomForUserID(_ userID: String) async -> Result<String?, ClientProxyError> {
|
||||
.failure(.failedRetrievingDirectRoom)
|
||||
|
@ -45,7 +45,7 @@ packages:
|
||||
# Element/Matrix dependencies
|
||||
MatrixRustSDK:
|
||||
url: https://github.com/matrix-org/matrix-rust-components-swift
|
||||
exactVersion: 1.0.106-alpha
|
||||
exactVersion: 1.0.107-alpha
|
||||
# path: ../matrix-rust-sdk
|
||||
DesignKit:
|
||||
path: DesignKit
|
||||
|
Loading…
x
Reference in New Issue
Block a user