diff --git a/ios/Runner/AppDelegate.swift b/ios/Runner/AppDelegate.swift index 2df78a2..7ab4a9a 100644 --- a/ios/Runner/AppDelegate.swift +++ b/ios/Runner/AppDelegate.swift @@ -27,14 +27,7 @@ func MissingArgumentError(message: String, details: Any?) -> FlutterError { Task.detached { await self.dnUpdater.updateAllLoop { [weak self] 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) - } - + self?.sites?.updateSite(site: site) // Send the refresh sites command on the main thread DispatchQueue.main.async { // Signal to the main screen to reload diff --git a/ios/Runner/Sites.swift b/ios/Runner/Sites.swift index 413515c..55c95ee 100644 --- a/ios/Runner/Sites.swift +++ b/ios/Runner/Sites.swift @@ -76,6 +76,17 @@ class Sites { func getContainer(id: String) -> SiteContainer? { return self.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) + } + + } } // FIXME: Make this class demonstrably Sendable