Fix not being able to switch accounts

This commit is contained in:
Shadowfacts 2022-01-26 22:37:00 -05:00
parent 0d89a0f38f
commit f320311a78
2 changed files with 15 additions and 9 deletions

View File

@ -130,6 +130,13 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
window!.overrideUserInterfaceStyle = .dark window!.overrideUserInterfaceStyle = .dark
} }
} }
func switchToAccount(_ account: LocalData.Account) {
LocalData.mostRecentAccountID = account.id
fervorController = FervorController(account: account)
createAppUI()
syncFromServer()
}
} }
@ -147,15 +154,6 @@ extension SceneDelegate: LoginViewControllerDelegate {
} }
} }
extension SceneDelegate: HomeViewControllerDelegate {
func switchToAccount(_ account: LocalData.Account) {
LocalData.mostRecentAccountID = account.id
fervorController = FervorController(account: account)
createAppUI()
syncFromServer()
}
}
#if targetEnvironment(macCatalyst) #if targetEnvironment(macCatalyst)
extension NSToolbarItem.Identifier { extension NSToolbarItem.Identifier {
static let toggleItemRead = NSToolbarItem.Identifier("ToggleItemRead") static let toggleItemRead = NSToolbarItem.Identifier("ToggleItemRead")

View File

@ -49,6 +49,7 @@ class AppSplitViewController: UISplitViewController {
setViewController(secondaryNav, for: .secondary) setViewController(secondaryNav, for: .secondary)
let home = HomeViewController(fervorController: fervorController) let home = HomeViewController(fervorController: fervorController)
home.delegate = self
let nav = AppNavigationController(rootViewController: home) let nav = AppNavigationController(rootViewController: home)
setViewController(nav, for: .compact) setViewController(nav, for: .compact)
} }
@ -61,3 +62,10 @@ extension AppSplitViewController: ItemsViewControllerDelegate {
} }
} }
extension AppSplitViewController: HomeViewControllerDelegate {
func switchToAccount(_ account: LocalData.Account) {
if let delegate = view.window?.windowScene?.delegate as? SceneDelegate {
delegate.switchToAccount(account)
}
}
}