mirror of
https://github.com/DefinedNet/mobile_nebula.git
synced 2025-02-15 16:25:26 +00:00
Add an "updateSite" method to Sites
This commit is contained in:
parent
821ceb41ce
commit
275b4a50fb
2 changed files with 12 additions and 8 deletions
|
@ -27,14 +27,7 @@ func MissingArgumentError(message: String, details: Any?) -> FlutterError {
|
||||||
|
|
||||||
Task.detached {
|
Task.detached {
|
||||||
await self.dnUpdater.updateAllLoop { [weak self] site in
|
await self.dnUpdater.updateAllLoop { [weak self] site in
|
||||||
// Signal the site has changed in case the current site details screen is active
|
self?.sites?.updateSite(site: site)
|
||||||
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)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Send the refresh sites command on the main thread
|
// Send the refresh sites command on the main thread
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
// Signal to the main screen to reload
|
// Signal to the main screen to reload
|
||||||
|
|
|
@ -76,6 +76,17 @@ class Sites {
|
||||||
func getContainer(id: String) -> SiteContainer? {
|
func getContainer(id: String) -> SiteContainer? {
|
||||||
return self.containers[id]
|
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
|
// FIXME: Make this class demonstrably Sendable
|
||||||
|
|
Loading…
Reference in a new issue