From 387552193629adba86743d463aa22331c239fbae Mon Sep 17 00:00:00 2001 From: Mauro Romito Date: Mon, 17 Jul 2023 21:04:52 +0200 Subject: [PATCH] sdk bump --- ElementX.xcodeproj/project.pbxproj | 4 +- .../xcshareddata/swiftpm/Package.resolved | 4 +- .../Mocks/Generated/SDKGeneratedMocks.swift | 35 +++++++++-------- .../Sources/Services/Client/ClientProxy.swift | 38 +++++++++---------- project.yml | 2 +- 5 files changed, 41 insertions(+), 42 deletions(-) diff --git a/ElementX.xcodeproj/project.pbxproj b/ElementX.xcodeproj/project.pbxproj index 6e3e309a6..b46f798f5 100644 --- a/ElementX.xcodeproj/project.pbxproj +++ b/ElementX.xcodeproj/project.pbxproj @@ -3618,7 +3618,7 @@ path = Timeline; sourceTree = ""; }; - "TEMP_BABAC1E3-4AC2-4E05-A4A7-2CB82B6F7C7E" /* element-x-ios */ = { + "TEMP_DD7E56C3-C054-403A-942D-AAD3ACD56CFE" /* element-x-ios */ = { isa = PBXGroup; children = ( 41553551C55AD59885840F0E /* secrets.xcconfig */, @@ -5327,7 +5327,7 @@ repositoryURL = "https://github.com/matrix-org/matrix-rust-components-swift"; requirement = { kind = exactVersion; - version = "1.0.99-alpha"; + version = "1.0.100-alpha"; }; }; 96495DD8554E2F39D3954354 /* XCRemoteSwiftPackageReference "posthog-ios" */ = { diff --git a/ElementX.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/ElementX.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index ce4d79689..abbc29ae8 100644 --- a/ElementX.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/ElementX.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -111,8 +111,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/matrix-org/matrix-rust-components-swift", "state" : { - "revision" : "3e2beb52294aa5dd87203cdcb3ac685f1a022c6b", - "version" : "1.0.99-alpha" + "revision" : "519bb8ed790646b73b63b8af125a65ed5be0465c", + "version" : "1.0.100-alpha" } }, { diff --git a/ElementX/Sources/Mocks/Generated/SDKGeneratedMocks.swift b/ElementX/Sources/Mocks/Generated/SDKGeneratedMocks.swift index 795a343d8..1aa5748bd 100644 --- a/ElementX/Sources/Mocks/Generated/SDKGeneratedMocks.swift +++ b/ElementX/Sources/Mocks/Generated/SDKGeneratedMocks.swift @@ -31,23 +31,6 @@ class SDKClientMock: SDKClientProtocol { 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` public var avatarUrlThrowableError: Error? @@ -274,7 +257,6 @@ class SDKClientMock: SDKClientProtocol { return getNotificationSettingsReturnValue } } - //MARK: - `getProfile` 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)) 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` public var unignoreUserUserIdThrowableError: Error? diff --git a/ElementX/Sources/Services/Client/ClientProxy.swift b/ElementX/Sources/Services/Client/ClientProxy.swift index 449750b43..15017093b 100644 --- a/ElementX/Sources/Services/Client/ClientProxy.swift +++ b/ElementX/Sources/Services/Client/ClientProxy.swift @@ -31,11 +31,11 @@ class ClientProxy: ClientProxyProtocol { private var roomListService: RoomListService? private var roomListStateUpdateTaskHandle: TaskHandle? - private var appService: App? - private var appServiceStateUpdateTaskHandle: TaskHandle? + private var syncService: SyncService? + private var syncServiceStateUpdateTaskHandle: TaskHandle? #warning("This is a workaround until the RustSDK provides a sync service state getter") - private var appServiceStateUpdateCurrentValueSubject = CurrentValueSubject(.terminated) + private var appServiceStateUpdateCurrentValueSubject = CurrentValueSubject(.terminated) var roomSummaryProvider: RoomSummaryProviderProtocol? var inviteSummaryProvider: RoomSummaryProviderProtocol? @@ -127,7 +127,7 @@ class ClientProxy: ClientProxyProtocol { Task { do { - try await appService?.start() + try await syncService?.start() } catch { MXLog.error("Failed starting app service with error: \(error)") } @@ -140,7 +140,7 @@ class ClientProxy: ClientProxyProtocol { MXLog.info("Stopping sync") do { - try appService?.pause() + try syncService?.pause() } catch { MXLog.error("Failed pausing app service with error: \(error)") } @@ -377,7 +377,7 @@ class ClientProxy: ClientProxyProtocol { do { MXLog.info("Restart the app service.") - try await self.appService?.start() + try await self.syncService?.start() } catch { MXLog.error("Failed restarting app service after error.") } @@ -402,17 +402,17 @@ class ClientProxy: ClientProxyProtocol { } private func configureAppService() async { - guard appService == nil else { + guard syncService == nil else { fatalError("This shouldn't be called more than once") } do { - let appService = try await client - .app() + let syncService = try await client + .syncService() .withEncryptionSync(withCrossProcessLock: appSettings.isEncryptionSyncEnabled, appIdentifier: "MainApp") .finish() - let roomListService = appService.roomListService() + let roomListService = syncService.roomListService() let eventStringBuilder = RoomEventStringBuilder(stateEventStringBuilder: RoomStateEventStringBuilder(userID: userID)) roomSummaryProvider = RoomSummaryProvider(roomListService: roomListService, @@ -423,10 +423,10 @@ class ClientProxy: ClientProxyProtocol { eventStringBuilder: eventStringBuilder, name: "Invites") - self.appService = appService + self.syncService = syncService self.roomListService = roomListService - appServiceStateUpdateTaskHandle = createAppServiceObserver(appService) + syncServiceStateUpdateTaskHandle = createSyncServiceStateObserver(syncService) roomListStateUpdateTaskHandle = createRoomListServiceObserver(roomListService) } catch { @@ -434,8 +434,8 @@ class ClientProxy: ClientProxyProtocol { } } - private func createAppServiceObserver(_ appService: App) -> TaskHandle { - appService.state(listener: AppStateObserverProxy { [weak self] state in + private func createSyncServiceStateObserver(_ syncService: SyncService) -> TaskHandle { + syncService.state(listener: SyncServiceStateObserverProxy { [weak self] state in guard let self else { return } MXLog.info("Received app service update: \(state)") @@ -443,7 +443,7 @@ class ClientProxy: ClientProxyProtocol { appServiceStateUpdateCurrentValueSubject.send(state) switch state { - case .running, .terminated: + case .running, .terminated, .idle: break case .error: restartSync(delay: .seconds(1)) @@ -509,14 +509,14 @@ extension ClientProxy: MediaLoaderProtocol { } } -private class AppStateObserverProxy: AppStateObserver { - private let onUpdateClosure: (AppState) -> Void +private class SyncServiceStateObserverProxy: SyncServiceStateObserver { + private let onUpdateClosure: (SyncServiceState) -> Void - init(onUpdateClosure: @escaping (AppState) -> Void) { + init(onUpdateClosure: @escaping (SyncServiceState) -> Void) { self.onUpdateClosure = onUpdateClosure } - func onUpdate(state: AppState) { + func onUpdate(state: SyncServiceState) { onUpdateClosure(state) } } diff --git a/project.yml b/project.yml index 3ecc74353..7a4850665 100644 --- a/project.yml +++ b/project.yml @@ -45,7 +45,7 @@ include: packages: MatrixRustSDK: url: https://github.com/matrix-org/matrix-rust-components-swift - exactVersion: 1.0.99-alpha + exactVersion: 1.0.100-alpha # path: ../matrix-rust-sdk DesignKit: path: DesignKit