forked from shadowfacts/Tusker
Fix crash when logging in for the first time
This commit is contained in:
parent
59c00b01dc
commit
c19b7ec2c6
|
@ -142,8 +142,6 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
|
|||
}
|
||||
|
||||
func activateAccount(_ account: LocalData.UserAccountInfo, animated: Bool) {
|
||||
let oldIndex = LocalData.shared.accounts.firstIndex(where: { $0.id == LocalData.shared.mostRecentAccountID })!
|
||||
let newIndex = LocalData.shared.accounts.firstIndex(of: account)!
|
||||
|
||||
LocalData.shared.setMostRecentAccount(account)
|
||||
window!.windowScene!.session.mastodonController = MastodonController.getForAccount(account)
|
||||
|
@ -151,7 +149,9 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
|
|||
let newRoot = createAppUI()
|
||||
if let container = window?.rootViewController as? AccountSwitchingContainerViewController {
|
||||
let direction: AccountSwitchingContainerViewController.AnimationDirection
|
||||
if animated {
|
||||
if animated,
|
||||
let oldIndex = LocalData.shared.accounts.firstIndex(where: { $0.id == LocalData.shared.mostRecentAccountID }),
|
||||
let newIndex = LocalData.shared.accounts.firstIndex(of: account) {
|
||||
direction = newIndex > oldIndex ? .upwards : .downwards
|
||||
} else {
|
||||
direction = .none
|
||||
|
|
Loading…
Reference in New Issue