mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-21 17:12:45 +02:00
Inject account manager into the session creator
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user