Add updateSite method to Sites

This commit is contained in:
Caleb Jasik 2025-02-19 17:21:07 -06:00
parent a4c7b4290c
commit 8819bfdbc2
No known key found for this signature in database
2 changed files with 12 additions and 8 deletions

View file

@ -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)

View file

@ -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 {