Skip to content

Commit

Permalink
Add updateSite method to Sites
Browse files Browse the repository at this point in the history
  • Loading branch information
jasikpark committed Feb 20, 2025
1 parent 0166bd3 commit e80a10e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
10 changes: 2 additions & 8 deletions ios/Runner/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,8 @@ func MissingArgumentError(message: String, details: Any?) -> FlutterError {
container!.updater.update(connected: site.connected ?? false, replaceSite: site)
}
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)
Expand Down
10 changes: 10 additions & 0 deletions ios/Runner/Sites.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit e80a10e

Please sign in to comment.