Fix fast account switching animating in wrong direction

This commit is contained in:
Shadowfacts 2021-01-28 23:20:38 -05:00
parent 4ed862120c
commit 949162bcab
1 changed files with 2 additions and 2 deletions

View File

@ -142,7 +142,7 @@ class MainSceneDelegate: UIResponder, UIWindowSceneDelegate {
} }
func activateAccount(_ account: LocalData.UserAccountInfo, animated: Bool) { func activateAccount(_ account: LocalData.UserAccountInfo, animated: Bool) {
let oldMostRecentAccount = LocalData.shared.mostRecentAccountID
LocalData.shared.setMostRecentAccount(account) LocalData.shared.setMostRecentAccount(account)
window!.windowScene!.session.mastodonController = MastodonController.getForAccount(account) window!.windowScene!.session.mastodonController = MastodonController.getForAccount(account)
@ -150,7 +150,7 @@ class MainSceneDelegate: UIResponder, UIWindowSceneDelegate {
if let container = window?.rootViewController as? AccountSwitchingContainerViewController { if let container = window?.rootViewController as? AccountSwitchingContainerViewController {
let direction: AccountSwitchingContainerViewController.AnimationDirection let direction: AccountSwitchingContainerViewController.AnimationDirection
if animated, if animated,
let oldIndex = LocalData.shared.accounts.firstIndex(where: { $0.id == LocalData.shared.mostRecentAccountID }), let oldIndex = LocalData.shared.accounts.firstIndex(where: { $0.id == oldMostRecentAccount }),
let newIndex = LocalData.shared.accounts.firstIndex(of: account) { let newIndex = LocalData.shared.accounts.firstIndex(of: account) {
direction = newIndex > oldIndex ? .upwards : .downwards direction = newIndex > oldIndex ? .upwards : .downwards
} else { } else {