From 1645d18747c46763ebaaa8065ac7e884b4418fa4 Mon Sep 17 00:00:00 2001 From: David Proskin Date: Wed, 27 Nov 2024 20:51:42 -0500 Subject: [PATCH] Bugfix - fixes reset settings menu items that weren't hooked up in SwiftUI --- Provenance/Main UI/PVAppDelegate.swift | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/Provenance/Main UI/PVAppDelegate.swift b/Provenance/Main UI/PVAppDelegate.swift index e9b0722685..5a416cd85a 100644 --- a/Provenance/Main UI/PVAppDelegate.swift +++ b/Provenance/Main UI/PVAppDelegate.swift @@ -104,7 +104,13 @@ final class PVAppDelegate: UIResponder, GameLaunchingAppDelegate, UIApplicationD .flatMap { _ in Future { promise in RomDatabase.refresh() - self.gameLibraryViewController?.checkROMs(false) + if let _ = self.gameLibraryViewController { + self.gameLibraryViewController?.checkROMs(false) + } else { + if let updates = await self.appState?.libraryUpdatesController { + await updates.importROMDirectories() + } + } promise(.success(())) } } @@ -117,7 +123,13 @@ final class PVAppDelegate: UIResponder, GameLaunchingAppDelegate, UIApplicationD Future { promise in do { try RomDatabase.sharedInstance.deleteAllGames() - self.gameLibraryViewController?.checkROMs(false) + if let _ = self.gameLibraryViewController { + self.gameLibraryViewController?.checkROMs(false) + } else { + if let updates = await self.appState?.libraryUpdatesController { + await updates.importROMDirectories() + } + } promise(.success(())) } catch { ELOG("Failed to refresh all objects. \(error.localizedDescription)") @@ -137,7 +149,13 @@ final class PVAppDelegate: UIResponder, GameLaunchingAppDelegate, UIApplicationD try RomDatabase.sharedInstance.deleteAllData() Task { await GameImporter.shared.initSystems() - self.gameLibraryViewController?.checkROMs(false) + if let _ = self.gameLibraryViewController { + self.gameLibraryViewController?.checkROMs(false) + } else { + if let updates = await self.appState?.libraryUpdatesController { + await updates.importROMDirectories() + } + } promise(.success(())) } } catch { @@ -520,6 +538,7 @@ final class PVAppDelegate: UIResponder, GameLaunchingAppDelegate, UIApplicationD viewModel: viewModel, rootViewController: rootViewController) + _initLibraryNotificationHandlers() return sideNav }