From 8819bfdbc210e35961ac95ab1cbb3c13b9a7f517 Mon Sep 17 00:00:00 2001 From: Caleb Jasik Date: Wed, 19 Feb 2025 17:21:07 -0600 Subject: [PATCH] Add `updateSite` method to `Sites` --- ios/Runner/AppDelegate.swift | 10 ++-------- ios/Runner/Sites.swift | 10 ++++++++++ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/ios/Runner/AppDelegate.swift b/ios/Runner/AppDelegate.swift index 3519c9b..ea99912 100644 --- a/ios/Runner/AppDelegate.swift +++ b/ios/Runner/AppDelegate.swift @@ -26,14 +26,8 @@ func MissingArgumentError(message: String, details: Any?) -> FlutterError { GeneratedPluginRegistrant.register(with: self) Task { - await dnUpdater.updateAllLoop { @MainActor site in - // Signal the site has changed in case the current site details screen is active - let container = self.sites?.getContainer(id: site.id) - if container != nil { - // Update references to the site with the new site config - container!.site = site - container!.updater.update(connected: site.connected ?? false, replaceSite: site) - } + await dnUpdater.updateAllLoop { site in + self.sites?.updateSite(site: site) // Signal to the main screen to reload self.ui?.invokeMethod("refreshSites", arguments: nil) diff --git a/ios/Runner/Sites.swift b/ios/Runner/Sites.swift index a411d84..7014e97 100644 --- a/ios/Runner/Sites.swift +++ b/ios/Runner/Sites.swift @@ -76,6 +76,16 @@ class Sites { func getContainer(id: String) -> SiteContainer? { return containers[id] } + + func updateSite(site: Site) { + // Signal the site has changed in case the current site details screen is active + let container = getContainer(id: site.id) + if container != nil { + // Update references to the site with the new site config + container!.site = site + container!.updater.update(connected: site.connected ?? false, replaceSite: site) + } + } } class SiteUpdater: NSObject, FlutterStreamHandler, @unchecked Sendable {