mirror of
https://github.com/DefinedNet/mobile_nebula.git
synced 2025-02-21 10:35:26 +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)
|
||||
|
||||
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)
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue