refactored the ClientProxy to:

- throw an error during the init
- to have its init directly instantiate the sync service and the providers

Update ElementX/Sources/Services/UserSession/UserSessionStore.swift

Co-authored-by: Doug <6060466+pixlwave@users.noreply.github.com>

renamed
This commit is contained in:
Mauro Romito 2025-03-06 12:16:28 +01:00 committed by Mauro
parent 4d01d2aa0b
commit 7373eabffb
10 changed files with 134 additions and 148 deletions

View File

@ -127,9 +127,7 @@ class PinnedEventsTimelineFlowCoordinator: FlowCoordinatorProtocol {
} }
private func presentMessageForwarding(with forwardingItem: MessageForwardingItem) { private func presentMessageForwarding(with forwardingItem: MessageForwardingItem) {
guard let roomSummaryProvider = userSession.clientProxy.alternateRoomSummaryProvider else { let roomSummaryProvider = userSession.clientProxy.alternateRoomSummaryProvider
fatalError()
}
let stackCoordinator = NavigationStackCoordinator() let stackCoordinator = NavigationStackCoordinator()

View File

@ -696,7 +696,7 @@ class RoomFlowCoordinator: FlowCoordinatorProtocol {
self.timelineController = timelineController self.timelineController = timelineController
let completionSuggestionService = CompletionSuggestionService(roomProxy: roomProxy, let completionSuggestionService = CompletionSuggestionService(roomProxy: roomProxy,
roomListPublisher: userSession.clientProxy.staticRoomSummaryProvider?.roomListPublisher.eraseToAnyPublisher() ?? Empty().replaceEmpty(with: []).eraseToAnyPublisher()) roomListPublisher: userSession.clientProxy.staticRoomSummaryProvider.roomListPublisher.eraseToAnyPublisher())
let composerDraftService = ComposerDraftService(roomProxy: roomProxy, timelineItemfactory: timelineItemFactory) let composerDraftService = ComposerDraftService(roomProxy: roomProxy, timelineItemfactory: timelineItemFactory)
let parameters = RoomScreenCoordinatorParameters(clientProxy: userSession.clientProxy, let parameters = RoomScreenCoordinatorParameters(clientProxy: userSession.clientProxy,
@ -1295,9 +1295,7 @@ class RoomFlowCoordinator: FlowCoordinatorProtocol {
} }
private func presentMessageForwarding(with forwardingItem: MessageForwardingItem) { private func presentMessageForwarding(with forwardingItem: MessageForwardingItem) {
guard let roomSummaryProvider = userSession.clientProxy.alternateRoomSummaryProvider else { let roomSummaryProvider = userSession.clientProxy.alternateRoomSummaryProvider
fatalError()
}
let stackCoordinator = NavigationStackCoordinator() let stackCoordinator = NavigationStackCoordinator()

View File

@ -831,9 +831,7 @@ class UserSessionFlowCoordinator: FlowCoordinatorProtocol {
// MARK: Global search // MARK: Global search
private func presentGlobalSearch() { private func presentGlobalSearch() {
guard let roomSummaryProvider = userSession.clientProxy.alternateRoomSummaryProvider else { let roomSummaryProvider = userSession.clientProxy.alternateRoomSummaryProvider
fatalError("Global search room summary provider unavailable")
}
let coordinator = GlobalSearchScreenCoordinator(parameters: .init(roomSummaryProvider: roomSummaryProvider, let coordinator = GlobalSearchScreenCoordinator(parameters: .init(roomSummaryProvider: roomSummaryProvider,
mediaProvider: userSession.mediaProvider)) mediaProvider: userSession.mediaProvider))
@ -935,9 +933,7 @@ class UserSessionFlowCoordinator: FlowCoordinatorProtocol {
// MARK: Sharing // MARK: Sharing
private func presentRoomSelectionScreen(sharePayload: ShareExtensionPayload, animated: Bool) { private func presentRoomSelectionScreen(sharePayload: ShareExtensionPayload, animated: Bool) {
guard let roomSummaryProvider = userSession.clientProxy.alternateRoomSummaryProvider else { let roomSummaryProvider = userSession.clientProxy.alternateRoomSummaryProvider
fatalError()
}
let stackCoordinator = NavigationStackCoordinator() let stackCoordinator = NavigationStackCoordinator()

View File

@ -13,7 +13,7 @@ struct ClientProxyMockConfiguration {
var userIDServerName: String? var userIDServerName: String?
var userID: String = RoomMemberProxyMock.mockMe.userID var userID: String = RoomMemberProxyMock.mockMe.userID
var deviceID: String? var deviceID: String?
var roomSummaryProvider: RoomSummaryProviderProtocol? = RoomSummaryProviderMock(.init()) var roomSummaryProvider: RoomSummaryProviderProtocol = RoomSummaryProviderMock(.init())
var roomDirectorySearchProxy: RoomDirectorySearchProxyProtocol? var roomDirectorySearchProxy: RoomDirectorySearchProxyProtocol?
var recoveryState: SecureBackupRecoveryState = .enabled var recoveryState: SecureBackupRecoveryState = .enabled
@ -86,7 +86,7 @@ extension ClientProxyMock {
resetIdentityReturnValue = .success(IdentityResetHandleSDKMock(.init())) resetIdentityReturnValue = .success(IdentityResetHandleSDKMock(.init()))
roomForIdentifierClosure = { [weak self] identifier in roomForIdentifierClosure = { [weak self] identifier in
guard let room = self?.roomSummaryProvider?.roomListPublisher.value.first(where: { $0.id == identifier }) else { guard let room = self?.roomSummaryProvider.roomListPublisher.value.first(where: { $0.id == identifier }) else {
return nil return nil
} }

View File

@ -2267,9 +2267,21 @@ class ClientProxyMock: ClientProxyProtocol, @unchecked Sendable {
} }
var underlyingIgnoredUsersPublisher: CurrentValuePublisher<[String]?, Never>! var underlyingIgnoredUsersPublisher: CurrentValuePublisher<[String]?, Never>!
var pusherNotificationClientIdentifier: String? var pusherNotificationClientIdentifier: String?
var roomSummaryProvider: RoomSummaryProviderProtocol? var roomSummaryProvider: RoomSummaryProviderProtocol {
var alternateRoomSummaryProvider: RoomSummaryProviderProtocol? get { return underlyingRoomSummaryProvider }
var staticRoomSummaryProvider: StaticRoomSummaryProviderProtocol? set(value) { underlyingRoomSummaryProvider = value }
}
var underlyingRoomSummaryProvider: RoomSummaryProviderProtocol!
var alternateRoomSummaryProvider: RoomSummaryProviderProtocol {
get { return underlyingAlternateRoomSummaryProvider }
set(value) { underlyingAlternateRoomSummaryProvider = value }
}
var underlyingAlternateRoomSummaryProvider: RoomSummaryProviderProtocol!
var staticRoomSummaryProvider: StaticRoomSummaryProviderProtocol {
get { return underlyingStaticRoomSummaryProvider }
set(value) { underlyingStaticRoomSummaryProvider = value }
}
var underlyingStaticRoomSummaryProvider: StaticRoomSummaryProviderProtocol!
var roomsToAwait: Set<String> { var roomsToAwait: Set<String> {
get { return underlyingRoomsToAwait } get { return underlyingRoomsToAwait }
set(value) { underlyingRoomsToAwait = value } set(value) { underlyingRoomsToAwait = value }

View File

@ -140,19 +140,19 @@ class JoinRoomScreenViewModel: JoinRoomScreenViewModelType, JoinRoomScreenViewMo
roomInfo = invitedRoomProxy.info roomInfo = invitedRoomProxy.info
case .knocked(let knockedRoomProxy): case .knocked(let knockedRoomProxy):
roomInfo = knockedRoomProxy.info roomInfo = knockedRoomProxy.info
if let roomSummaryProvider = clientProxy.staticRoomSummaryProvider { membershipStateChangeCancellable = clientProxy
membershipStateChangeCancellable = roomSummaryProvider.roomListPublisher .staticRoomSummaryProvider
.compactMap { summaries -> Void? in .roomListPublisher
guard let roomSummary = summaries.first(where: { $0.id == roomInfo?.id }), .compactMap { summaries -> Void? in
roomSummary.roomListItem.membership() != .knocked else { guard let roomSummary = summaries.first(where: { $0.id == roomInfo?.id }),
return nil roomSummary.roomListItem.membership() != .knocked else {
} return nil
return ()
} }
.sink { [weak self] in return ()
Task { await self?.loadRoomDetails() } }
} .sink { [weak self] in
} Task { await self?.loadRoomDetails() }
}
case .banned(let bannedRoomProxy): case .banned(let bannedRoomProxy):
roomInfo = bannedRoomProxy.info roomInfo = bannedRoomProxy.info
default: default:

View File

@ -20,13 +20,13 @@ class ClientProxy: ClientProxyProtocol {
private let mediaLoader: MediaLoaderProtocol private let mediaLoader: MediaLoaderProtocol
private let clientQueue: DispatchQueue private let clientQueue: DispatchQueue
private var roomListService: RoomListService? private var roomListService: RoomListService
// periphery: ignore - only for retain // periphery: ignore - only for retain
private var roomListStateUpdateTaskHandle: TaskHandle? private var roomListStateUpdateTaskHandle: TaskHandle?
// periphery: ignore - only for retain // periphery: ignore - only for retain
private var roomListStateLoadingStateUpdateTaskHandle: TaskHandle? private var roomListStateLoadingStateUpdateTaskHandle: TaskHandle?
private var syncService: SyncService? private var syncService: SyncService
// periphery: ignore - only for retain // periphery: ignore - only for retain
private var syncServiceStateUpdateTaskHandle: TaskHandle? private var syncServiceStateUpdateTaskHandle: TaskHandle?
@ -43,10 +43,10 @@ class ClientProxy: ClientProxyProtocol {
// These following summary providers both operate on the same allRooms() list but // These following summary providers both operate on the same allRooms() list but
// can apply their own filtering and pagination // can apply their own filtering and pagination
private(set) var roomSummaryProvider: RoomSummaryProviderProtocol? private(set) var roomSummaryProvider: RoomSummaryProviderProtocol
private(set) var alternateRoomSummaryProvider: RoomSummaryProviderProtocol? private(set) var alternateRoomSummaryProvider: RoomSummaryProviderProtocol
private(set) var staticRoomSummaryProvider: StaticRoomSummaryProviderProtocol? private(set) var staticRoomSummaryProvider: StaticRoomSummaryProviderProtocol
let notificationSettings: NotificationSettingsProxyProtocol let notificationSettings: NotificationSettingsProxyProtocol
@ -139,7 +139,7 @@ class ClientProxy: ClientProxyProtocol {
init(client: ClientProtocol, init(client: ClientProtocol,
needsSlidingSyncMigration: Bool, needsSlidingSyncMigration: Bool,
networkMonitor: NetworkMonitorProtocol, networkMonitor: NetworkMonitorProtocol,
appSettings: AppSettings) async { appSettings: AppSettings) async throws {
self.client = client self.client = client
self.networkMonitor = networkMonitor self.networkMonitor = networkMonitor
self.appSettings = appSettings self.appSettings = appSettings
@ -154,6 +154,21 @@ class ClientProxy: ClientProxyProtocol {
self.needsSlidingSyncMigration = needsSlidingSyncMigration self.needsSlidingSyncMigration = needsSlidingSyncMigration
let configuredAppService = try await ClientProxyServices(client: client,
actionsSubject: actionsSubject,
notificationSettings: notificationSettings,
appSettings: appSettings)
syncService = configuredAppService.syncService
roomListService = configuredAppService.roomListService
roomSummaryProvider = configuredAppService.roomSummaryProvider
alternateRoomSummaryProvider = configuredAppService.alternateRoomSummaryProvider
staticRoomSummaryProvider = configuredAppService.staticRoomSummaryProvider
syncServiceStateUpdateTaskHandle = createSyncServiceStateObserver(syncService)
roomListStateUpdateTaskHandle = createRoomListServiceObserver(roomListService)
roomListStateLoadingStateUpdateTaskHandle = createRoomListLoadingStateUpdateObserver(roomListService)
delegateHandle = client.setDelegate(delegate: ClientDelegateWrapper { [weak self] isSoftLogout in delegateHandle = client.setDelegate(delegate: ClientDelegateWrapper { [weak self] isSoftLogout in
self?.hasEncounteredAuthError = true self?.hasEncounteredAuthError = true
self?.actionsSubject.send(.receivedAuthError(isSoftLogout: isSoftLogout)) self?.actionsSubject.send(.receivedAuthError(isSoftLogout: isSoftLogout))
@ -169,8 +184,6 @@ class ClientProxy: ClientProxyProtocol {
} }
.store(in: &cancellables) .store(in: &cancellables)
await configureAppService()
loadUserAvatarURLFromCache() loadUserAvatarURLFromCache()
ignoredUsersListenerTaskHandle = client.subscribeToIgnoredUsers(listener: IgnoredUsersListenerProxy { [weak self] ignoredUsers in ignoredUsersListenerTaskHandle = client.subscribeToIgnoredUsers(listener: IgnoredUsersListenerProxy { [weak self] ignoredUsers in
@ -281,7 +294,7 @@ class ClientProxy: ClientProxyProtocol {
MXLog.info("Starting sync") MXLog.info("Starting sync")
Task { Task {
await syncService?.start() await syncService.start()
// If we are using OIDC we want to cache the account management URL in volatile memory on the SDK side. // If we are using OIDC we want to cache the account management URL in volatile memory on the SDK side.
// To avoid the cache being invalidated while the app is backgrounded, we cache at every sync start. // To avoid the cache being invalidated while the app is backgrounded, we cache at every sync start.
@ -322,12 +335,6 @@ class ClientProxy: ClientProxyProtocol {
restartTask = nil restartTask = nil
} }
guard let syncService else {
MXLog.warning("No sync service to stop.")
completion?()
return
}
// Capture the sync service strongly as this method is called on deinit and so the // Capture the sync service strongly as this method is called on deinit and so the
// existence of self when the Task executes is questionable and would sometimes crash. // existence of self when the Task executes is questionable and would sometimes crash.
// Note: This isn't strictly necessary now given the unwrap above, but leaving the code as // Note: This isn't strictly necessary now given the unwrap above, but leaving the code as
@ -493,12 +500,6 @@ class ClientProxy: ClientProxyProtocol {
return room return room
} }
// Else wait for the visible rooms list to go into fully loaded
guard let roomSummaryProvider else {
MXLog.error("Rooms summary provider not setup yet")
return nil
}
if !roomSummaryProvider.statePublisher.value.isLoaded { if !roomSummaryProvider.statePublisher.value.isLoaded {
_ = await roomSummaryProvider.statePublisher.values.first { $0.isLoaded } _ = await roomSummaryProvider.statePublisher.values.first { $0.isLoaded }
} }
@ -524,33 +525,11 @@ class ClientProxy: ClientProxyProtocol {
} }
func roomSummaryForIdentifier(_ identifier: String) -> RoomSummary? { func roomSummaryForIdentifier(_ identifier: String) -> RoomSummary? {
// the alternate room summary provider is not impacted by filtering staticRoomSummaryProvider.roomListPublisher.value.first(where: { $0.id == identifier })
guard let provider = staticRoomSummaryProvider else {
MXLog.verbose("Missing room summary provider")
return nil
}
guard let roomSummary = provider.roomListPublisher.value.first(where: { $0.id == identifier }) else {
MXLog.verbose("Missing room summary, count: \(provider.roomListPublisher.value.count)")
return nil
}
return roomSummary
} }
func roomSummaryForAlias(_ alias: String) -> RoomSummary? { func roomSummaryForAlias(_ alias: String) -> RoomSummary? {
// the alternate room summary provider is not impacted by filtering staticRoomSummaryProvider.roomListPublisher.value.first(where: { $0.canonicalAlias == alias || $0.alternativeAliases.contains(alias) })
guard let provider = staticRoomSummaryProvider else {
MXLog.verbose("Missing room summary provider")
return nil
}
guard let roomSummary = provider.roomListPublisher.value.first(where: { $0.canonicalAlias == alias || $0.alternativeAliases.contains(alias) }) else {
MXLog.verbose("Missing room summary, count: \(provider.roomListPublisher.value.count)")
return nil
}
return roomSummary
} }
func loadUserDisplayName() async -> Result<Void, ClientProxyError> { func loadUserDisplayName() async -> Result<Void, ClientProxyError> {
@ -840,62 +819,6 @@ class ClientProxy: ClientProxyProtocol {
} }
} }
private func configureAppService() async {
guard syncService == nil else {
fatalError("This shouldn't be called more than once")
}
do {
let syncService = try await client
.syncService()
.withCrossProcessLock()
.withUtdHook(delegate: ClientDecryptionErrorDelegate(actionsSubject: actionsSubject))
.finish()
let roomListService = syncService.roomListService()
let roomMessageEventStringBuilder = RoomMessageEventStringBuilder(attributedStringBuilder: AttributedStringBuilder(cacheKey: "roomList",
mentionBuilder: PlainMentionBuilder()), destination: .roomList)
let eventStringBuilder = RoomEventStringBuilder(stateEventStringBuilder: RoomStateEventStringBuilder(userID: userID, shouldDisambiguateDisplayNames: false),
messageEventStringBuilder: roomMessageEventStringBuilder,
shouldDisambiguateDisplayNames: false,
shouldPrefixSenderName: true)
roomSummaryProvider = RoomSummaryProvider(roomListService: roomListService,
eventStringBuilder: eventStringBuilder,
name: "AllRooms",
shouldUpdateVisibleRange: true,
notificationSettings: notificationSettings,
appSettings: appSettings)
try await roomSummaryProvider?.setRoomList(roomListService.allRooms())
alternateRoomSummaryProvider = RoomSummaryProvider(roomListService: roomListService,
eventStringBuilder: eventStringBuilder,
name: "AlternateAllRooms",
notificationSettings: notificationSettings,
appSettings: appSettings)
try await alternateRoomSummaryProvider?.setRoomList(roomListService.allRooms())
staticRoomSummaryProvider = RoomSummaryProvider(roomListService: roomListService,
eventStringBuilder: eventStringBuilder,
name: "StaticAllRooms",
roomListPageSize: .max,
notificationSettings: notificationSettings,
appSettings: appSettings)
try await staticRoomSummaryProvider?.setRoomList(roomListService.allRooms())
self.syncService = syncService
self.roomListService = roomListService
syncServiceStateUpdateTaskHandle = createSyncServiceStateObserver(syncService)
roomListStateUpdateTaskHandle = createRoomListServiceObserver(roomListService)
roomListStateLoadingStateUpdateTaskHandle = createRoomListLoadingStateUpdateObserver(roomListService)
} catch {
MXLog.error("Failed building room list service with error: \(error)")
}
}
private func createSyncServiceStateObserver(_ syncService: SyncService) -> TaskHandle { private func createSyncServiceStateObserver(_ syncService: SyncService) -> TaskHandle {
syncService.state(listener: SyncServiceStateObserverProxy { [weak self] state in syncService.state(listener: SyncServiceStateObserverProxy { [weak self] state in
guard let self else { return } guard let self else { return }
@ -967,11 +890,6 @@ class ClientProxy: ClientProxyProtocol {
}() }()
private func buildRoomForIdentifier(_ roomID: String) async -> RoomProxyType? { private func buildRoomForIdentifier(_ roomID: String) async -> RoomProxyType? {
guard let roomListService else {
MXLog.error("Failed retrieving room: \(roomID), room list service not set up")
return nil
}
do { do {
let roomListItem = try roomListService.room(roomId: roomID) let roomListItem = try roomListService.room(roomId: roomID)
@ -1205,3 +1123,57 @@ private class SendQueueRoomErrorListenerProxy: SendQueueRoomErrorListener {
onErrorClosure(roomId, error) onErrorClosure(roomId, error)
} }
} }
private struct ClientProxyServices {
let syncService: SyncService
let roomListService: RoomListService
let roomSummaryProvider: RoomSummaryProviderProtocol
let alternateRoomSummaryProvider: RoomSummaryProviderProtocol
let staticRoomSummaryProvider: StaticRoomSummaryProviderProtocol
init(client: ClientProtocol,
actionsSubject: PassthroughSubject<ClientProxyAction, Never>,
notificationSettings: NotificationSettingsProxyProtocol,
appSettings: AppSettings) async throws {
let syncService = try await client
.syncService()
.withCrossProcessLock()
.withUtdHook(delegate: ClientDecryptionErrorDelegate(actionsSubject: actionsSubject))
.finish()
let roomListService = syncService.roomListService()
let roomMessageEventStringBuilder = RoomMessageEventStringBuilder(attributedStringBuilder: AttributedStringBuilder(cacheKey: "roomList",
mentionBuilder: PlainMentionBuilder()), destination: .roomList)
let eventStringBuilder = try RoomEventStringBuilder(stateEventStringBuilder: RoomStateEventStringBuilder(userID: client.userId(), shouldDisambiguateDisplayNames: false),
messageEventStringBuilder: roomMessageEventStringBuilder,
shouldDisambiguateDisplayNames: false,
shouldPrefixSenderName: true)
roomSummaryProvider = RoomSummaryProvider(roomListService: roomListService,
eventStringBuilder: eventStringBuilder,
name: "AllRooms",
shouldUpdateVisibleRange: true,
notificationSettings: notificationSettings,
appSettings: appSettings)
try await roomSummaryProvider.setRoomList(roomListService.allRooms())
alternateRoomSummaryProvider = RoomSummaryProvider(roomListService: roomListService,
eventStringBuilder: eventStringBuilder,
name: "AlternateAllRooms",
notificationSettings: notificationSettings,
appSettings: appSettings)
try await alternateRoomSummaryProvider.setRoomList(roomListService.allRooms())
staticRoomSummaryProvider = RoomSummaryProvider(roomListService: roomListService,
eventStringBuilder: eventStringBuilder,
name: "StaticAllRooms",
roomListPageSize: .max,
notificationSettings: notificationSettings,
appSettings: appSettings)
try await staticRoomSummaryProvider.setRoomList(roomListService.allRooms())
self.syncService = syncService
self.roomListService = roomListService
}
}

View File

@ -94,15 +94,15 @@ protocol ClientProxyProtocol: AnyObject, MediaLoaderProtocol {
var pusherNotificationClientIdentifier: String? { get } var pusherNotificationClientIdentifier: String? { get }
var roomSummaryProvider: RoomSummaryProviderProtocol? { get } var roomSummaryProvider: RoomSummaryProviderProtocol { get }
/// Used for listing rooms that shouldn't be affected by the main `roomSummaryProvider` filtering /// Used for listing rooms that shouldn't be affected by the main `roomSummaryProvider` filtering
/// But can still be filtered by queries, since this may be shared across multiple views, remember to reset /// But can still be filtered by queries, since this may be shared across multiple views, remember to reset
/// The filtering state when you are done with it /// The filtering state when you are done with it
var alternateRoomSummaryProvider: RoomSummaryProviderProtocol? { get } var alternateRoomSummaryProvider: RoomSummaryProviderProtocol { get }
/// Used for listing rooms, can't be filtered nor its state observed /// Used for listing rooms, can't be filtered nor its state observed
var staticRoomSummaryProvider: StaticRoomSummaryProviderProtocol? { get } var staticRoomSummaryProvider: StaticRoomSummaryProviderProtocol { get }
var roomsToAwait: Set<String> { get set } var roomsToAwait: Set<String> { get set }

View File

@ -64,7 +64,7 @@ class UserSessionStore: UserSessionStoreProtocol {
do { do {
let session = try client.session() let session = try client.session()
let userID = try client.userId() let userID = try client.userId()
let clientProxy = await setupProxyForClient(client, needsSlidingSyncMigration: false) let clientProxy = try await setupProxyForClient(client, needsSlidingSyncMigration: false)
keychainController.setRestorationToken(RestorationToken(session: session, keychainController.setRestorationToken(RestorationToken(session: session,
sessionDirectories: sessionDirectories, sessionDirectories: sessionDirectories,
@ -138,17 +138,26 @@ class UserSessionStore: UserSessionStoreProtocol {
MXLog.info("Set up session for user \(credentials.userID) at: \(credentials.restorationToken.sessionDirectories)") MXLog.info("Set up session for user \(credentials.userID) at: \(credentials.restorationToken.sessionDirectories)")
return await .success(setupProxyForClient(client, needsSlidingSyncMigration: credentials.restorationToken.needsSlidingSyncMigration)) return try await .success(setupProxyForClient(client, needsSlidingSyncMigration: credentials.restorationToken.needsSlidingSyncMigration))
} catch UserSessionStoreError.failedSettingUpClientProxy(let error) {
// If this has failed, there is likely something wrong with the creation of the sync service
// There is nothing we can do, but at the same time we don't want the user to the get logged out
// So it's better to crash here and let the app restart
fatalError("Failed setting up the client proxy with error: \(error)")
} catch { } catch {
MXLog.error("Failed restoring login with error: \(error)") MXLog.error("Failed restoring login with error: \(error)")
return .failure(.failedRestoringLogin) return .failure(.failedRestoringLogin)
} }
} }
private func setupProxyForClient(_ client: ClientProtocol, needsSlidingSyncMigration: Bool) async -> ClientProxyProtocol { private func setupProxyForClient(_ client: ClientProtocol, needsSlidingSyncMigration: Bool) async throws -> ClientProxyProtocol {
await ClientProxy(client: client, do {
needsSlidingSyncMigration: needsSlidingSyncMigration, return try await ClientProxy(client: client,
networkMonitor: networkMonitor, needsSlidingSyncMigration: needsSlidingSyncMigration,
appSettings: appSettings) networkMonitor: networkMonitor,
appSettings: appSettings)
} catch {
throw UserSessionStoreError.failedSettingUpClientProxy(error)
}
} }
} }

View File

@ -12,6 +12,7 @@ enum UserSessionStoreError: Error {
case missingCredentials case missingCredentials
case failedRestoringLogin case failedRestoringLogin
case failedSettingUpSession case failedSettingUpSession
case failedSettingUpClientProxy(Error)
} }
// sourcery: AutoMockable // sourcery: AutoMockable