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 21, 2025
1 parent 88a617a commit c0eb5df
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
12 changes: 8 additions & 4 deletions ios/Runner/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ func MissingArgumentError(message: String, details: Any?) -> FlutterError {
if err != nil {
return result(
CallFailedError(
message: "Error while parsing certificate(s)", details: err!.localizedDescription))
message: "Error while parsing certificate(s)", details: err!.localizedDescription
))
}

return result(json)
Expand All @@ -110,7 +111,8 @@ func MissingArgumentError(message: String, details: Any?) -> FlutterError {
return result(
CallFailedError(
message: "Error while verifying certificate and private key",
details: err!.localizedDescription))
details: err!.localizedDescription
))
}

return result(valid)
Expand All @@ -122,7 +124,8 @@ func MissingArgumentError(message: String, details: Any?) -> FlutterError {
if err != nil {
return result(
CallFailedError(
message: "Error while generating key pairs", details: err!.localizedDescription))
message: "Error while generating key pairs", details: err!.localizedDescription
))
}

return result(kp)
Expand Down Expand Up @@ -240,7 +243,8 @@ func MissingArgumentError(message: String, details: Any?) -> FlutterError {
} catch {
return result(
CallFailedError(
message: "Could not start site", details: error.localizedDescription))
message: "Could not start site", details: error.localizedDescription
))
}
}
}
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 c0eb5df

Please sign in to comment.