Removed forwarded properties from the UserSessionProtocol as the ClientProxy is already fully exposed

This commit is contained in:
Stefan Ceriu
2024-05-27 14:47:55 +03:00
committed by Stefan Ceriu
parent 3a904ebc9d
commit e93e75778a
7 changed files with 12 additions and 24 deletions
@@ -465,15 +465,15 @@ class AppCoordinator: AppCoordinatorProtocol, AuthenticationFlowCoordinatorDeleg
} }
Task { Task {
let credentials = SoftLogoutScreenCredentials(userID: userSession.userID, let credentials = SoftLogoutScreenCredentials(userID: userSession.clientProxy.userID,
homeserverName: userSession.homeserver, homeserverName: userSession.clientProxy.homeserver,
userDisplayName: userSession.clientProxy.userDisplayNamePublisher.value ?? "", userDisplayName: userSession.clientProxy.userDisplayNamePublisher.value ?? "",
deviceID: userSession.deviceID) deviceID: userSession.clientProxy.deviceID)
let authenticationService = AuthenticationServiceProxy(userSessionStore: userSessionStore, let authenticationService = AuthenticationServiceProxy(userSessionStore: userSessionStore,
encryptionKeyProvider: EncryptionKeyProvider(), encryptionKeyProvider: EncryptionKeyProvider(),
appSettings: appSettings) appSettings: appSettings)
_ = await authenticationService.configure(for: userSession.homeserver) _ = await authenticationService.configure(for: userSession.clientProxy.homeserver)
let parameters = SoftLogoutScreenCoordinatorParameters(authenticationService: authenticationService, let parameters = SoftLogoutScreenCoordinatorParameters(authenticationService: authenticationService,
credentials: credentials, credentials: credentials,
@@ -705,7 +705,7 @@ class AppCoordinator: AppCoordinatorProtocol, AuthenticationFlowCoordinatorDeleg
stopSync() stopSync()
userSessionFlowCoordinator?.stop() userSessionFlowCoordinator?.stop()
let userID = userSession.userID let userID = userSession.clientProxy.userID
tearDownUserSession() tearDownUserSession()
// Allow for everything to deallocate properly // Allow for everything to deallocate properly
@@ -27,10 +27,6 @@ extension UserSessionMock {
self.init() self.init()
clientProxy = configuration.clientProxy clientProxy = configuration.clientProxy
userID = clientProxy.userID
deviceID = clientProxy.deviceID
homeserver = clientProxy.homeserver
mediaProvider = MockMediaProvider() mediaProvider = MockMediaProvider()
voiceMessageMediaManager = VoiceMessageMediaManagerMock() voiceMessageMediaManager = VoiceMessageMediaManagerMock()
@@ -50,7 +50,7 @@ class HomeScreenViewModel: HomeScreenViewModelType, HomeScreenViewModelProtocol
roomSummaryProvider = userSession.clientProxy.roomSummaryProvider roomSummaryProvider = userSession.clientProxy.roomSummaryProvider
super.init(initialViewState: .init(userID: userSession.userID), super.init(initialViewState: .init(userID: userSession.clientProxy.userID),
imageProvider: userSession.mediaProvider) imageProvider: userSession.mediaProvider)
userSession.clientProxy.userAvatarURLPublisher userSession.clientProxy.userAvatarURLPublisher
@@ -236,7 +236,7 @@ class HomeScreenViewModel: HomeScreenViewModelType, HomeScreenViewModelProtocol
analyticsService.signpost.beginFirstRooms() analyticsService.signpost.beginFirstRooms()
let hasUserBeenMigrated = appSettings.migratedAccounts[userSession.userID] == true let hasUserBeenMigrated = appSettings.migratedAccounts[userSession.clientProxy.userID] == true
if !hasUserBeenMigrated { if !hasUserBeenMigrated {
state.roomListMode = .migration state.roomListMode = .migration
@@ -248,7 +248,7 @@ class HomeScreenViewModel: HomeScreenViewModelType, HomeScreenViewModelProtocol
.sink { [weak self] callback in .sink { [weak self] callback in
guard let self, case .receivedSyncUpdate = callback else { return } guard let self, case .receivedSyncUpdate = callback else { return }
migrationCancellable = nil migrationCancellable = nil
appSettings.migratedAccounts[userSession.userID] = true appSettings.migratedAccounts[userSession.clientProxy.userID] = true
MXLog.info("Received first sync response, updating room list mode") MXLog.info("Received first sync response, updating room list mode")
@@ -279,7 +279,7 @@ class HomeScreenViewModel: HomeScreenViewModelType, HomeScreenViewModelProtocol
} }
private func updateRoomListMode(with roomSummaryProviderState: RoomSummaryProviderState) { 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" // Ignore room summary provider updates while "migrating"
return return
} }
@@ -27,8 +27,8 @@ class SettingsScreenViewModel: SettingsScreenViewModelType, SettingsScreenViewMo
} }
init(userSession: UserSessionProtocol, appSettings: AppSettings) { init(userSession: UserSessionProtocol, appSettings: AppSettings) {
super.init(initialViewState: .init(deviceID: userSession.deviceID, super.init(initialViewState: .init(deviceID: userSession.clientProxy.deviceID,
userID: userSession.userID, userID: userSession.clientProxy.userID,
showDeveloperOptions: appSettings.isDevelopmentBuild), showDeveloperOptions: appSettings.isDevelopmentBuild),
imageProvider: userSession.mediaProvider) imageProvider: userSession.mediaProvider)
@@ -41,7 +41,7 @@ class StartChatScreenViewModel: StartChatScreenViewModelType, StartChatScreenVie
self.userIndicatorController = userIndicatorController self.userIndicatorController = userIndicatorController
self.userDiscoveryService = userDiscoveryService 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() setupBindings()
@@ -24,10 +24,6 @@ class UserSession: UserSessionProtocol {
private var authErrorCancellable: AnyCancellable? private var authErrorCancellable: AnyCancellable?
var userID: String { clientProxy.userID }
var deviceID: String? { clientProxy.deviceID }
var homeserver: String { clientProxy.homeserver }
let clientProxy: ClientProxyProtocol let clientProxy: ClientProxyProtocol
let mediaProvider: MediaProviderProtocol let mediaProvider: MediaProviderProtocol
let voiceMessageMediaManager: VoiceMessageMediaManagerProtocol let voiceMessageMediaManager: VoiceMessageMediaManagerProtocol
@@ -28,10 +28,6 @@ struct SessionSecurityState: Equatable {
// sourcery: AutoMockable // sourcery: AutoMockable
protocol UserSessionProtocol { protocol UserSessionProtocol {
var homeserver: String { get }
var userID: String { get }
var deviceID: String? { get }
var clientProxy: ClientProxyProtocol { get } var clientProxy: ClientProxyProtocol { get }
var mediaProvider: MediaProviderProtocol { get } var mediaProvider: MediaProviderProtocol { get }
var voiceMessageMediaManager: VoiceMessageMediaManagerProtocol { get } var voiceMessageMediaManager: VoiceMessageMediaManagerProtocol { get }