diff --git a/ElementX/Sources/Application/AppCoordinator.swift b/ElementX/Sources/Application/AppCoordinator.swift index ab3acaa92..5c3c1ecb9 100644 --- a/ElementX/Sources/Application/AppCoordinator.swift +++ b/ElementX/Sources/Application/AppCoordinator.swift @@ -465,15 +465,15 @@ class AppCoordinator: AppCoordinatorProtocol, AuthenticationFlowCoordinatorDeleg } Task { - let credentials = SoftLogoutScreenCredentials(userID: userSession.userID, - homeserverName: userSession.homeserver, + let credentials = SoftLogoutScreenCredentials(userID: userSession.clientProxy.userID, + homeserverName: userSession.clientProxy.homeserver, userDisplayName: userSession.clientProxy.userDisplayNamePublisher.value ?? "", - deviceID: userSession.deviceID) + deviceID: userSession.clientProxy.deviceID) let authenticationService = AuthenticationServiceProxy(userSessionStore: userSessionStore, encryptionKeyProvider: EncryptionKeyProvider(), appSettings: appSettings) - _ = await authenticationService.configure(for: userSession.homeserver) + _ = await authenticationService.configure(for: userSession.clientProxy.homeserver) let parameters = SoftLogoutScreenCoordinatorParameters(authenticationService: authenticationService, credentials: credentials, @@ -705,7 +705,7 @@ class AppCoordinator: AppCoordinatorProtocol, AuthenticationFlowCoordinatorDeleg stopSync() userSessionFlowCoordinator?.stop() - let userID = userSession.userID + let userID = userSession.clientProxy.userID tearDownUserSession() // Allow for everything to deallocate properly diff --git a/ElementX/Sources/Mocks/UserSessionMock.swift b/ElementX/Sources/Mocks/UserSessionMock.swift index a3be8e1eb..824fb5617 100644 --- a/ElementX/Sources/Mocks/UserSessionMock.swift +++ b/ElementX/Sources/Mocks/UserSessionMock.swift @@ -27,10 +27,6 @@ extension UserSessionMock { self.init() clientProxy = configuration.clientProxy - userID = clientProxy.userID - deviceID = clientProxy.deviceID - homeserver = clientProxy.homeserver - mediaProvider = MockMediaProvider() voiceMessageMediaManager = VoiceMessageMediaManagerMock() diff --git a/ElementX/Sources/Screens/HomeScreen/HomeScreenViewModel.swift b/ElementX/Sources/Screens/HomeScreen/HomeScreenViewModel.swift index 5cb3215cb..1d613ccf4 100644 --- a/ElementX/Sources/Screens/HomeScreen/HomeScreenViewModel.swift +++ b/ElementX/Sources/Screens/HomeScreen/HomeScreenViewModel.swift @@ -50,7 +50,7 @@ class HomeScreenViewModel: HomeScreenViewModelType, HomeScreenViewModelProtocol roomSummaryProvider = userSession.clientProxy.roomSummaryProvider - super.init(initialViewState: .init(userID: userSession.userID), + super.init(initialViewState: .init(userID: userSession.clientProxy.userID), imageProvider: userSession.mediaProvider) userSession.clientProxy.userAvatarURLPublisher @@ -236,7 +236,7 @@ class HomeScreenViewModel: HomeScreenViewModelType, HomeScreenViewModelProtocol analyticsService.signpost.beginFirstRooms() - let hasUserBeenMigrated = appSettings.migratedAccounts[userSession.userID] == true + let hasUserBeenMigrated = appSettings.migratedAccounts[userSession.clientProxy.userID] == true if !hasUserBeenMigrated { state.roomListMode = .migration @@ -248,7 +248,7 @@ class HomeScreenViewModel: HomeScreenViewModelType, HomeScreenViewModelProtocol .sink { [weak self] callback in guard let self, case .receivedSyncUpdate = callback else { return } migrationCancellable = nil - appSettings.migratedAccounts[userSession.userID] = true + appSettings.migratedAccounts[userSession.clientProxy.userID] = true MXLog.info("Received first sync response, updating room list mode") @@ -279,7 +279,7 @@ class HomeScreenViewModel: HomeScreenViewModelType, HomeScreenViewModelProtocol } private func updateRoomListMode(with roomSummaryProviderState: RoomSummaryProviderState) { - guard appSettings.migratedAccounts[userSession.userID] == true else { + guard appSettings.migratedAccounts[userSession.clientProxy.userID] == true else { // Ignore room summary provider updates while "migrating" return } diff --git a/ElementX/Sources/Screens/Settings/SettingsScreen/SettingsScreenViewModel.swift b/ElementX/Sources/Screens/Settings/SettingsScreen/SettingsScreenViewModel.swift index 03baadbc2..9f1ec2652 100644 --- a/ElementX/Sources/Screens/Settings/SettingsScreen/SettingsScreenViewModel.swift +++ b/ElementX/Sources/Screens/Settings/SettingsScreen/SettingsScreenViewModel.swift @@ -27,8 +27,8 @@ class SettingsScreenViewModel: SettingsScreenViewModelType, SettingsScreenViewMo } init(userSession: UserSessionProtocol, appSettings: AppSettings) { - super.init(initialViewState: .init(deviceID: userSession.deviceID, - userID: userSession.userID, + super.init(initialViewState: .init(deviceID: userSession.clientProxy.deviceID, + userID: userSession.clientProxy.userID, showDeveloperOptions: appSettings.isDevelopmentBuild), imageProvider: userSession.mediaProvider) diff --git a/ElementX/Sources/Screens/StartChatScreen/StartChatScreenViewModel.swift b/ElementX/Sources/Screens/StartChatScreen/StartChatScreenViewModel.swift index e9079439d..a609c0125 100644 --- a/ElementX/Sources/Screens/StartChatScreen/StartChatScreenViewModel.swift +++ b/ElementX/Sources/Screens/StartChatScreen/StartChatScreenViewModel.swift @@ -41,7 +41,7 @@ class StartChatScreenViewModel: StartChatScreenViewModelType, StartChatScreenVie self.userIndicatorController = userIndicatorController self.userDiscoveryService = userDiscoveryService - super.init(initialViewState: StartChatScreenViewState(userID: userSession.userID), imageProvider: userSession.mediaProvider) + super.init(initialViewState: StartChatScreenViewState(userID: userSession.clientProxy.userID), imageProvider: userSession.mediaProvider) setupBindings() diff --git a/ElementX/Sources/Services/Session/UserSession.swift b/ElementX/Sources/Services/Session/UserSession.swift index 19012aa46..5f416b865 100644 --- a/ElementX/Sources/Services/Session/UserSession.swift +++ b/ElementX/Sources/Services/Session/UserSession.swift @@ -23,10 +23,6 @@ class UserSession: UserSessionProtocol { private var cancellables = Set() private var authErrorCancellable: AnyCancellable? - - var userID: String { clientProxy.userID } - var deviceID: String? { clientProxy.deviceID } - var homeserver: String { clientProxy.homeserver } let clientProxy: ClientProxyProtocol let mediaProvider: MediaProviderProtocol diff --git a/ElementX/Sources/Services/Session/UserSessionProtocol.swift b/ElementX/Sources/Services/Session/UserSessionProtocol.swift index 2cff031f0..d47beb2dd 100644 --- a/ElementX/Sources/Services/Session/UserSessionProtocol.swift +++ b/ElementX/Sources/Services/Session/UserSessionProtocol.swift @@ -28,10 +28,6 @@ struct SessionSecurityState: Equatable { // sourcery: AutoMockable protocol UserSessionProtocol { - var homeserver: String { get } - var userID: String { get } - var deviceID: String? { get } - var clientProxy: ClientProxyProtocol { get } var mediaProvider: MediaProviderProtocol { get } var voiceMessageMediaManager: VoiceMessageMediaManagerProtocol { get }