Make account switching work again

This commit is contained in:
Nathan Mattes 2023-06-02 11:10:29 +02:00
parent 1bb8e64574
commit aa9a6ee701
4 changed files with 5 additions and 6 deletions

View File

@ -217,7 +217,7 @@ extension SceneCoordinator {
let rootViewController: UIViewController
do {
let _authentication = AuthenticationServiceProvider.shared.authentications.first
let _authentication = AuthenticationServiceProvider.shared.authenticationSortedByActivation().first
let _authContext = _authentication.flatMap { AuthContext(authentication: $0) }
self.authContext = _authContext

View File

@ -50,8 +50,8 @@ public extension AuthenticationServiceProvider {
authentications.first(where: { $0.userAccessToken == userAccessToken })
}
func sortByActivation() { // fixme: why do we need this?
authentications = authentications.sorted(by: { $0.activedAt > $1.activedAt })
func authenticationSortedByActivation() -> [MastodonAuthentication] { // fixme: why do we need this?
return authentications.sorted(by: { $0.activedAt > $1.activedAt })
}
func restore() {

View File

@ -119,7 +119,7 @@ public final class AuthenticationService: NSObject {
}
.assign(to: &$mastodonAuthenticationBoxes)
AuthenticationServiceProvider.shared.sortByActivation()
AuthenticationServiceProvider.shared.authentications = AuthenticationServiceProvider.shared.authenticationSortedByActivation()
}
}

View File

@ -179,8 +179,7 @@ extension ShareViewController {
extension ShareViewController {
private func setupAuthContext() throws -> AuthContext? {
AuthenticationServiceProvider.shared.sortByActivation()
let _authentication = AuthenticationServiceProvider.shared.authentications.first
let _authentication = AuthenticationServiceProvider.shared.authenticationSortedByActivation().first
let _authContext = _authentication.flatMap { AuthContext(authentication: $0) }
return _authContext
}