forked from core/mobile_nebula
* Refresh Sites when a site is saved (closes #89) * Update with iOS side fix
This commit is contained in:
parent
6108bf801b
commit
974c7a4eed
|
@ -210,7 +210,6 @@ class MainActivity: FlutterActivity() {
|
|||
val gson = Gson()
|
||||
site = gson.fromJson(call.arguments as String, IncomingSite::class.java)
|
||||
siteDir = site.save(context)
|
||||
|
||||
} catch (err: Exception) {
|
||||
//TODO: is toString the best or .message?
|
||||
return result.error("failure", err.toString(), null)
|
||||
|
@ -220,6 +219,8 @@ class MainActivity: FlutterActivity() {
|
|||
return result.error("failure", "Site config was incomplete, please review and try again", null)
|
||||
}
|
||||
|
||||
sites?.refreshSites()
|
||||
|
||||
result.success(null)
|
||||
}
|
||||
|
||||
|
|
|
@ -184,9 +184,11 @@ func MissingArgumentError(message: String, details: Any?) -> FlutterError {
|
|||
return result(CallFailedError(message: "Failed to save site", details: error!.localizedDescription))
|
||||
}
|
||||
|
||||
self.sites?.loadSites { _, _ in
|
||||
result(nil)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func startSite(call: FlutterMethodCall, result: @escaping FlutterResult) {
|
||||
guard let args = call.arguments as? Dictionary<String, String> else { return result(NoArgumentsError()) }
|
||||
|
|
|
@ -26,8 +26,13 @@ class Sites {
|
|||
}
|
||||
|
||||
sites?.values.forEach{ site in
|
||||
let updater = SiteUpdater(messenger: self.messenger!, site: site)
|
||||
self.containers[site.id] = SiteContainer(site: site, updater: updater)
|
||||
var updater = self.containers[site.id]?.updater
|
||||
if (updater != nil) {
|
||||
updater!.setSite(site: site)
|
||||
} else {
|
||||
updater = SiteUpdater(messenger: self.messenger!, site: site)
|
||||
}
|
||||
self.containers[site.id] = SiteContainer(site: site, updater: updater!)
|
||||
}
|
||||
|
||||
let justSites = self.containers.mapValues {
|
||||
|
@ -113,6 +118,10 @@ class SiteUpdater: NSObject, FlutterStreamHandler {
|
|||
self.configObserver?.resume()
|
||||
}
|
||||
|
||||
func setSite(site: Site) {
|
||||
self.site = site
|
||||
}
|
||||
|
||||
/// onListen is called when flutter code attaches an event listener
|
||||
func onListen(withArguments arguments: Any?, eventSink events: @escaping FlutterEventSink) -> FlutterError? {
|
||||
eventSink = events;
|
||||
|
|
|
@ -230,6 +230,7 @@ class _SiteDetailScreenState extends State<SiteDetailScreen> {
|
|||
site: widget.site,
|
||||
onSave: (site) async {
|
||||
changed = true;
|
||||
setState(() {});
|
||||
});
|
||||
});
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue