forked from shadowfacts/Tusker
Temporary fix for crash that occurs when switching accounts immediately
after adding a new one
This commit is contained in:
parent
804636dcbb
commit
af821081b0
|
@ -57,8 +57,16 @@ class PreferencesNavigationController: UINavigationController {
|
|||
}
|
||||
|
||||
@objc func activateAccount(_ notification: Notification) {
|
||||
// TODO: this is a temporary measure
|
||||
// when switching accounts shortly after adding a new one, there is an old instance of PreferncesNavigationController still around
|
||||
// which tries to handle the notification but is unable to because it no longer is in a window (and therefore doesn't have a scene delegate)
|
||||
// the propper fix would be to figure out what's leaking instances of this class
|
||||
guard let window = self.view.window,
|
||||
let windowScene = window.windowScene,
|
||||
let sceneDelegate = windowScene.delegate as? SceneDelegate else {
|
||||
return
|
||||
}
|
||||
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)
|
||||
|
@ -66,7 +74,11 @@ class PreferencesNavigationController: UINavigationController {
|
|||
}
|
||||
|
||||
@objc func userLoggedOut() {
|
||||
let sceneDelegate = self.view.window!.windowScene!.delegate as! SceneDelegate
|
||||
guard let window = self.view.window,
|
||||
let windowScene = window.windowScene,
|
||||
let sceneDelegate = windowScene.delegate as? SceneDelegate else {
|
||||
return
|
||||
}
|
||||
isSwitchingAccounts = true
|
||||
dismiss(animated: true) { // dismiss preferences
|
||||
sceneDelegate.logoutCurrent()
|
||||
|
|
Loading…
Reference in New Issue