diff --git a/Tusker/Screens/Preferences/PreferencesNavigationController.swift b/Tusker/Screens/Preferences/PreferencesNavigationController.swift index 5b93c231..3b4d7b4f 100644 --- a/Tusker/Screens/Preferences/PreferencesNavigationController.swift +++ b/Tusker/Screens/Preferences/PreferencesNavigationController.swift @@ -10,6 +10,8 @@ import UIKit import SwiftUI class PreferencesNavigationController: UINavigationController { + + private var isSwitchingAccounts = false init(mastodonController: MastodonController) { let view = PreferencesView() @@ -33,8 +35,10 @@ class PreferencesNavigationController: UINavigationController { override func viewWillDisappear(_ animated: Bool) { super.viewWillDisappear(animated) - // workaround for onDisappear not being called when a modally presented UIHostingController is dismissed - NotificationCenter.default.post(name: .preferencesChanged, object: nil) + if !isSwitchingAccounts { + // workaround for onDisappear not being called when a modally presented UIHostingController is dismissed + NotificationCenter.default.post(name: .preferencesChanged, object: nil) + } } @objc func donePressed() { @@ -55,6 +59,7 @@ class PreferencesNavigationController: UINavigationController { @objc func activateAccount(_ notification: Notification) { let account = notification.userInfo!["account"] as! LocalData.UserAccountInfo let sceneDelegate = self.view.window!.windowScene!.delegate as! SceneDelegate + isSwitchingAccounts = true dismiss(animated: true) { // dismiss preferences sceneDelegate.activateAccount(account) } @@ -62,6 +67,7 @@ class PreferencesNavigationController: UINavigationController { @objc func userLoggedOut() { let sceneDelegate = self.view.window!.windowScene!.delegate as! SceneDelegate + isSwitchingAccounts = true dismiss(animated: true) { // dismiss preferences sceneDelegate.logoutCurrent() }