This commit is contained in:
Mauro Romito
2023-07-17 21:04:52 +02:00
committed by Mauro
parent 57f48a4b9e
commit 3875521936
5 changed files with 41 additions and 42 deletions

View File

@@ -3618,7 +3618,7 @@
path = Timeline;
sourceTree = "<group>";
};
"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" */ = {

View File

@@ -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"
}
},
{

View File

@@ -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?

View File

@@ -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<AppState, Never>(.terminated)
private var appServiceStateUpdateCurrentValueSubject = CurrentValueSubject<SyncServiceState, Never>(.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)
}
}

View File

@@ -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