Inject account manager into the session creator

This commit is contained in:
ismailgulek 2022-06-06 16:15:53 +03:00
parent ea097c92b5
commit 322767dfa1
No known key found for this signature in database
GPG key ID: E96336D42D9470A9

View file

@ -27,6 +27,13 @@ protocol SessionCreatorProtocol {
/// A struct that provides common functionality to create a new session.
struct SessionCreator: SessionCreatorProtocol {
private let accountManager: MXKAccountManager
init(withAccountManager accountManager: MXKAccountManager = .shared()) {
self.accountManager = accountManager
}
func createSession(credentials: MXCredentials, client: AuthenticationRestClient) -> MXSession {
// Report the new account in account manager
if credentials.identityServer == nil {
@ -39,7 +46,7 @@ struct SessionCreator: SessionCreatorProtocol {
account.identityServerURL = identityServer
}
MXKAccountManager.shared().addAccount(account, andOpenSession: true)
accountManager.addAccount(account, andOpenSession: true)
return account.mxSession
}
}