Fixes not showing toast view if error occurs during initial sources fetch

This commit is contained in:
Riley Testut
2024-02-15 19:31:11 -06:00
committed by Magesh K
parent c0e780cbbd
commit d07b3e6c3a

View File

@@ -21,7 +21,7 @@ final class LaunchViewController: RSTLaunchViewController, UIDocumentPickerDeleg
{
private var didFinishLaunching = false
private var destinationViewController: UIViewController!
private var destinationViewController: TabBarController!
override var launchConditions: [RSTLaunchCondition] {
let isDatabaseStarted = RSTLaunchCondition(condition: { DatabaseManager.shared.isStarted }) { (completionHandler) in
@@ -259,6 +259,9 @@ final class LaunchViewController: RSTLaunchViewController, UIDocumentPickerDeleg
else {
start_auto_mounter(documentsDirectory)
}
// Create destinationViewController now so view controllers can register for receiving Notifications.
self.destinationViewController = self.storyboard!.instantiateViewController(withIdentifier: "tabBarController") as? TabBarController
}
}
@@ -307,6 +310,10 @@ extension LaunchViewController
AppManager.shared.updateAllSources { result in
guard case .failure(let error) = result else { return }
Logger.main.error("Failed to update sources on launch. \(error.localizedDescription, privacy: .public)")
let toastView = ToastView(error: error)
toastView.addTarget(self.destinationViewController, action: #selector(TabBarController.presentSources), for: .touchUpInside)
toastView.show(in: self.destinationViewController.selectedViewController ?? self.destinationViewController)
}
self.updateKnownSources()