mirror of
https://github.com/home-assistant/iOS.git
synced 2026-05-02 15:24:14 -05:00
Revert "Remove unecessary model updates from app lifecycle" (#3546)
Reverts home-assistant/iOS#3531
This commit is contained in:
committed by
GitHub
parent
5f48bb222a
commit
107f875a91
@@ -388,10 +388,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
|
||||
_ = Realm.live()
|
||||
Action.setupObserver()
|
||||
NotificationCategory.setupObserver()
|
||||
Current.modelManager.cleanup().cauterize()
|
||||
Current.modelManager.subscribe(isAppInForeground: {
|
||||
UIApplication.shared.applicationState == .active
|
||||
})
|
||||
}
|
||||
|
||||
private func setupMenus() {
|
||||
|
||||
@@ -104,11 +104,38 @@ final class WebViewSceneDelegate: NSObject, UIWindowSceneDelegate {
|
||||
#if targetEnvironment(macCatalyst)
|
||||
WindowScenesManager.shared.didDiscardScene(scene)
|
||||
#endif
|
||||
|
||||
DataWidgetsUpdater.update()
|
||||
}
|
||||
|
||||
func sceneDidEnterBackground(_ scene: UIScene) {
|
||||
if #available(iOS 17.0, *) {
|
||||
// if a widget is pending confirmation to execute it's action
|
||||
// this will reset that and the widget will be restored to default state
|
||||
_ = ResetAllCustomWidgetConfirmationAppIntent()
|
||||
}
|
||||
DataWidgetsUpdater.update()
|
||||
Current.modelManager.unsubscribe()
|
||||
Current.appDatabaseUpdater.stop()
|
||||
}
|
||||
|
||||
func sceneDidBecomeActive(_ scene: UIScene) {
|
||||
updateAppDatabase()
|
||||
removeWidgetsCache()
|
||||
Current.modelManager.cleanup().cauterize()
|
||||
Current.modelManager.subscribe(isAppInForeground: {
|
||||
UIApplication.shared.applicationState == .active
|
||||
})
|
||||
|
||||
Current.appDatabaseUpdater.update()
|
||||
Current.panelsUpdater.update()
|
||||
|
||||
let widgetsCacheFile = AppConstants.widgetsCacheURL
|
||||
|
||||
// Clean up widgets cache file
|
||||
do {
|
||||
try FileManager.default.removeItem(at: widgetsCacheFile)
|
||||
} catch {
|
||||
Current.Log.error("Failed to remove widgets cache file: \(error)")
|
||||
}
|
||||
}
|
||||
|
||||
func windowScene(
|
||||
@@ -138,23 +165,3 @@ final class WebViewSceneDelegate: NSObject, UIWindowSceneDelegate {
|
||||
urlHandler?.handle(userActivity: userActivity)
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - App database & cache
|
||||
|
||||
extension WebViewSceneDelegate {
|
||||
private func updateAppDatabase() {
|
||||
Current.appDatabaseUpdater.update()
|
||||
Current.panelsUpdater.update()
|
||||
}
|
||||
|
||||
private func removeWidgetsCache() {
|
||||
let widgetsCacheFile = AppConstants.widgetsCacheURL
|
||||
|
||||
// Clean up widgets cache file
|
||||
do {
|
||||
try FileManager.default.removeItem(at: widgetsCacheFile)
|
||||
} catch {
|
||||
Current.Log.info("Did not remove widgets cache file: \(error)")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user