mirror of
https://github.com/DefinedNet/mobile_nebula.git
synced 2025-02-22 19:15:27 +00:00
Add updateSite
method to Sites
This commit is contained in:
parent
a4c7b4290c
commit
8819bfdbc2
2 changed files with 12 additions and 8 deletions
|
@ -26,14 +26,8 @@ func MissingArgumentError(message: String, details: Any?) -> FlutterError {
|
||||||
GeneratedPluginRegistrant.register(with: self)
|
GeneratedPluginRegistrant.register(with: self)
|
||||||
|
|
||||||
Task {
|
Task {
|
||||||
await dnUpdater.updateAllLoop { @MainActor site in
|
await dnUpdater.updateAllLoop { 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)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Signal to the main screen to reload
|
// Signal to the main screen to reload
|
||||||
self.ui?.invokeMethod("refreshSites", arguments: nil)
|
self.ui?.invokeMethod("refreshSites", arguments: nil)
|
||||||
|
|
|
@ -76,6 +76,16 @@ class Sites {
|
||||||
func getContainer(id: String) -> SiteContainer? {
|
func getContainer(id: String) -> SiteContainer? {
|
||||||
return containers[id]
|
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 {
|
class SiteUpdater: NSObject, FlutterStreamHandler, @unchecked Sendable {
|
||||||
|
|
Loading…
Reference in a new issue