From d07b3e6c3aa9a7a993afd6c6084e2a6c28edf364 Mon Sep 17 00:00:00 2001 From: Riley Testut Date: Thu, 15 Feb 2024 19:31:11 -0600 Subject: [PATCH] Fixes not showing toast view if error occurs during initial sources fetch --- AltStore/LaunchViewController.swift | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/AltStore/LaunchViewController.swift b/AltStore/LaunchViewController.swift index e5bf85cf..38fae3a3 100644 --- a/AltStore/LaunchViewController.swift +++ b/AltStore/LaunchViewController.swift @@ -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()