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

@ -131,6 +131,13 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
}
}
func switchToAccount(_ account: LocalData.Account) {
LocalData.mostRecentAccountID = account.id
fervorController = FervorController(account: account)
createAppUI()
syncFromServer()
}
}
extension SceneDelegate: LoginViewControllerDelegate {
@ -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)
extension NSToolbarItem.Identifier {
static let toggleItemRead = NSToolbarItem.Identifier("ToggleItemRead")

View File

@ -49,6 +49,7 @@ class AppSplitViewController: UISplitViewController {
setViewController(secondaryNav, for: .secondary)
let home = HomeViewController(fervorController: fervorController)
home.delegate = self
let nav = AppNavigationController(rootViewController: home)
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)
}
}
}