Add an "updateSite" method to Sites

This commit is contained in:
Caleb Jasik 2025-02-12 12:38:57 -06:00
parent 821ceb41ce
commit 275b4a50fb
No known key found for this signature in database
2 changed files with 12 additions and 8 deletions

View file

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

View file

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