mirror of
https://github.com/vector-im/element-ios.git
synced 2024-09-28 23:32:41 +00:00
Inject account manager into the session creator
This commit is contained in:
parent
ea097c92b5
commit
322767dfa1
1 changed files with 8 additions and 1 deletions
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue