From 2c56902389fae4664d6d5a28dbb5478fe9f075e0 Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Wed, 29 May 2024 22:23:09 -0700 Subject: [PATCH] Remove old account UI state when logging out --- Tusker/Scenes/MainSceneDelegate.swift | 3 +++ .../Main/AccountSwitchingContainerViewController.swift | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/Tusker/Scenes/MainSceneDelegate.swift b/Tusker/Scenes/MainSceneDelegate.swift index fd88a828..b83de24c 100644 --- a/Tusker/Scenes/MainSceneDelegate.swift +++ b/Tusker/Scenes/MainSceneDelegate.swift @@ -247,6 +247,9 @@ class MainSceneDelegate: UIResponder, UIWindowSceneDelegate, TuskerSceneDelegate LogoutService(accountInfo: account).run() if UserAccountsManager.shared.onboardingComplete { activateAccount(UserAccountsManager.shared.accounts.first!, animated: false) + if let container = window?.rootViewController as? AccountSwitchingContainerViewController { + container.removeAccount(account) + } } else { window!.rootViewController = createOnboardingUI() } diff --git a/Tusker/Screens/Main/AccountSwitchingContainerViewController.swift b/Tusker/Screens/Main/AccountSwitchingContainerViewController.swift index 4c467981..4eb58e68 100644 --- a/Tusker/Screens/Main/AccountSwitchingContainerViewController.swift +++ b/Tusker/Screens/Main/AccountSwitchingContainerViewController.swift @@ -49,6 +49,10 @@ class AccountSwitchingContainerViewController: UIViewController { } } + func removeAccount(_ account: UserAccountInfo) { + viewControllers.removeValue(forKey: account.id) + } + func setRoot(_ newRootProvider: () -> AccountSwitchableViewController, for account: UserAccountInfo, animating direction: AnimationDirection) { let oldRoot = self.root if direction == .none {