This commit is contained in:
Mauro Romito
2023-07-17 21:04:52 +02:00
committed by Mauro
parent 79fcfcd61b
commit 63935ceab3
5 changed files with 41 additions and 42 deletions
+2 -2
View File
@@ -3618,7 +3618,7 @@
path = Timeline; path = Timeline;
sourceTree = "<group>"; sourceTree = "<group>";
}; };
"TEMP_BABAC1E3-4AC2-4E05-A4A7-2CB82B6F7C7E" /* element-x-ios */ = { "TEMP_DD7E56C3-C054-403A-942D-AAD3ACD56CFE" /* element-x-ios */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
41553551C55AD59885840F0E /* secrets.xcconfig */, 41553551C55AD59885840F0E /* secrets.xcconfig */,
@@ -5327,7 +5327,7 @@
repositoryURL = "https://github.com/matrix-org/matrix-rust-components-swift"; repositoryURL = "https://github.com/matrix-org/matrix-rust-components-swift";
requirement = { requirement = {
kind = exactVersion; kind = exactVersion;
version = "1.0.99-alpha"; version = "1.0.100-alpha";
}; };
}; };
96495DD8554E2F39D3954354 /* XCRemoteSwiftPackageReference "posthog-ios" */ = { 96495DD8554E2F39D3954354 /* XCRemoteSwiftPackageReference "posthog-ios" */ = {
@@ -111,8 +111,8 @@
"kind" : "remoteSourceControl", "kind" : "remoteSourceControl",
"location" : "https://github.com/matrix-org/matrix-rust-components-swift", "location" : "https://github.com/matrix-org/matrix-rust-components-swift",
"state" : { "state" : {
"revision" : "3e2beb52294aa5dd87203cdcb3ac685f1a022c6b", "revision" : "519bb8ed790646b73b63b8af125a65ed5be0465c",
"version" : "1.0.99-alpha" "version" : "1.0.100-alpha"
} }
}, },
{ {
@@ -31,23 +31,6 @@ class SDKClientMock: SDKClientProtocol {
return accountDataEventTypeReturnValue return accountDataEventTypeReturnValue
} }
} }
//MARK: - `app`
public var appCallsCount = 0
public var appCalled: Bool {
return appCallsCount > 0
}
public var appReturnValue: AppBuilder!
public var appClosure: (() -> AppBuilder)?
public func `app`() -> AppBuilder {
appCallsCount += 1
if let appClosure = appClosure {
return appClosure()
} else {
return appReturnValue
}
}
//MARK: - `avatarUrl` //MARK: - `avatarUrl`
public var avatarUrlThrowableError: Error? public var avatarUrlThrowableError: Error?
@@ -274,7 +257,6 @@ class SDKClientMock: SDKClientProtocol {
return getNotificationSettingsReturnValue return getNotificationSettingsReturnValue
} }
} }
//MARK: - `getProfile` //MARK: - `getProfile`
public var getProfileUserIdThrowableError: Error? public var getProfileUserIdThrowableError: Error?
@@ -570,6 +552,23 @@ class SDKClientMock: SDKClientProtocol {
setPusherIdentifiersKindAppDisplayNameDeviceDisplayNameProfileTagLangReceivedInvocations.append((identifiers: identifiers, kind: kind, appDisplayName: appDisplayName, deviceDisplayName: deviceDisplayName, profileTag: profileTag, lang: lang)) setPusherIdentifiersKindAppDisplayNameDeviceDisplayNameProfileTagLangReceivedInvocations.append((identifiers: identifiers, kind: kind, appDisplayName: appDisplayName, deviceDisplayName: deviceDisplayName, profileTag: profileTag, lang: lang))
try setPusherIdentifiersKindAppDisplayNameDeviceDisplayNameProfileTagLangClosure?(`identifiers`, `kind`, `appDisplayName`, `deviceDisplayName`, `profileTag`, `lang`) try setPusherIdentifiersKindAppDisplayNameDeviceDisplayNameProfileTagLangClosure?(`identifiers`, `kind`, `appDisplayName`, `deviceDisplayName`, `profileTag`, `lang`)
} }
//MARK: - `syncService`
public var syncServiceCallsCount = 0
public var syncServiceCalled: Bool {
return syncServiceCallsCount > 0
}
public var syncServiceReturnValue: SyncServiceBuilder!
public var syncServiceClosure: (() -> SyncServiceBuilder)?
public func `syncService`() -> SyncServiceBuilder {
syncServiceCallsCount += 1
if let syncServiceClosure = syncServiceClosure {
return syncServiceClosure()
} else {
return syncServiceReturnValue
}
}
//MARK: - `unignoreUser` //MARK: - `unignoreUser`
public var unignoreUserUserIdThrowableError: Error? public var unignoreUserUserIdThrowableError: Error?
@@ -31,11 +31,11 @@ class ClientProxy: ClientProxyProtocol {
private var roomListService: RoomListService? private var roomListService: RoomListService?
private var roomListStateUpdateTaskHandle: TaskHandle? private var roomListStateUpdateTaskHandle: TaskHandle?
private var appService: App? private var syncService: SyncService?
private var appServiceStateUpdateTaskHandle: TaskHandle? private var syncServiceStateUpdateTaskHandle: TaskHandle?
#warning("This is a workaround until the RustSDK provides a sync service state getter") #warning("This is a workaround until the RustSDK provides a sync service state getter")
private var appServiceStateUpdateCurrentValueSubject = CurrentValueSubject<AppState, Never>(.terminated) private var appServiceStateUpdateCurrentValueSubject = CurrentValueSubject<SyncServiceState, Never>(.terminated)
var roomSummaryProvider: RoomSummaryProviderProtocol? var roomSummaryProvider: RoomSummaryProviderProtocol?
var inviteSummaryProvider: RoomSummaryProviderProtocol? var inviteSummaryProvider: RoomSummaryProviderProtocol?
@@ -127,7 +127,7 @@ class ClientProxy: ClientProxyProtocol {
Task { Task {
do { do {
try await appService?.start() try await syncService?.start()
} catch { } catch {
MXLog.error("Failed starting app service with error: \(error)") MXLog.error("Failed starting app service with error: \(error)")
} }
@@ -140,7 +140,7 @@ class ClientProxy: ClientProxyProtocol {
MXLog.info("Stopping sync") MXLog.info("Stopping sync")
do { do {
try appService?.pause() try syncService?.pause()
} catch { } catch {
MXLog.error("Failed pausing app service with error: \(error)") MXLog.error("Failed pausing app service with error: \(error)")
} }
@@ -377,7 +377,7 @@ class ClientProxy: ClientProxyProtocol {
do { do {
MXLog.info("Restart the app service.") MXLog.info("Restart the app service.")
try await self.appService?.start() try await self.syncService?.start()
} catch { } catch {
MXLog.error("Failed restarting app service after error.") MXLog.error("Failed restarting app service after error.")
} }
@@ -402,17 +402,17 @@ class ClientProxy: ClientProxyProtocol {
} }
private func configureAppService() async { private func configureAppService() async {
guard appService == nil else { guard syncService == nil else {
fatalError("This shouldn't be called more than once") fatalError("This shouldn't be called more than once")
} }
do { do {
let appService = try await client let syncService = try await client
.app() .syncService()
.withEncryptionSync(withCrossProcessLock: appSettings.isEncryptionSyncEnabled, .withEncryptionSync(withCrossProcessLock: appSettings.isEncryptionSyncEnabled,
appIdentifier: "MainApp") appIdentifier: "MainApp")
.finish() .finish()
let roomListService = appService.roomListService() let roomListService = syncService.roomListService()
let eventStringBuilder = RoomEventStringBuilder(stateEventStringBuilder: RoomStateEventStringBuilder(userID: userID)) let eventStringBuilder = RoomEventStringBuilder(stateEventStringBuilder: RoomStateEventStringBuilder(userID: userID))
roomSummaryProvider = RoomSummaryProvider(roomListService: roomListService, roomSummaryProvider = RoomSummaryProvider(roomListService: roomListService,
@@ -423,10 +423,10 @@ class ClientProxy: ClientProxyProtocol {
eventStringBuilder: eventStringBuilder, eventStringBuilder: eventStringBuilder,
name: "Invites") name: "Invites")
self.appService = appService self.syncService = syncService
self.roomListService = roomListService self.roomListService = roomListService
appServiceStateUpdateTaskHandle = createAppServiceObserver(appService) syncServiceStateUpdateTaskHandle = createSyncServiceStateObserver(syncService)
roomListStateUpdateTaskHandle = createRoomListServiceObserver(roomListService) roomListStateUpdateTaskHandle = createRoomListServiceObserver(roomListService)
} catch { } catch {
@@ -434,8 +434,8 @@ class ClientProxy: ClientProxyProtocol {
} }
} }
private func createAppServiceObserver(_ appService: App) -> TaskHandle { private func createSyncServiceStateObserver(_ syncService: SyncService) -> TaskHandle {
appService.state(listener: AppStateObserverProxy { [weak self] state in syncService.state(listener: SyncServiceStateObserverProxy { [weak self] state in
guard let self else { return } guard let self else { return }
MXLog.info("Received app service update: \(state)") MXLog.info("Received app service update: \(state)")
@@ -443,7 +443,7 @@ class ClientProxy: ClientProxyProtocol {
appServiceStateUpdateCurrentValueSubject.send(state) appServiceStateUpdateCurrentValueSubject.send(state)
switch state { switch state {
case .running, .terminated: case .running, .terminated, .idle:
break break
case .error: case .error:
restartSync(delay: .seconds(1)) restartSync(delay: .seconds(1))
@@ -509,14 +509,14 @@ extension ClientProxy: MediaLoaderProtocol {
} }
} }
private class AppStateObserverProxy: AppStateObserver { private class SyncServiceStateObserverProxy: SyncServiceStateObserver {
private let onUpdateClosure: (AppState) -> Void private let onUpdateClosure: (SyncServiceState) -> Void
init(onUpdateClosure: @escaping (AppState) -> Void) { init(onUpdateClosure: @escaping (SyncServiceState) -> Void) {
self.onUpdateClosure = onUpdateClosure self.onUpdateClosure = onUpdateClosure
} }
func onUpdate(state: AppState) { func onUpdate(state: SyncServiceState) {
onUpdateClosure(state) onUpdateClosure(state)
} }
} }
+1 -1
View File
@@ -45,7 +45,7 @@ include:
packages: packages:
MatrixRustSDK: MatrixRustSDK:
url: https://github.com/matrix-org/matrix-rust-components-swift url: https://github.com/matrix-org/matrix-rust-components-swift
exactVersion: 1.0.99-alpha exactVersion: 1.0.100-alpha
# path: ../matrix-rust-sdk # path: ../matrix-rust-sdk
DesignKit: DesignKit:
path: DesignKit path: DesignKit