mirror of
https://github.com/DefinedNet/mobile_nebula.git
synced 2025-02-14 16:05:25 +00:00
Try to refactor towards async await & results
This commit is contained in:
parent
da6a82f9ad
commit
26c7cd4122
4 changed files with 19 additions and 13 deletions
|
@ -288,7 +288,7 @@
|
||||||
attributes = {
|
attributes = {
|
||||||
BuildIndependentTargetsInParallel = YES;
|
BuildIndependentTargetsInParallel = YES;
|
||||||
LastSwiftUpdateCheck = 1140;
|
LastSwiftUpdateCheck = 1140;
|
||||||
LastUpgradeCheck = 1510;
|
LastUpgradeCheck = 1620;
|
||||||
ORGANIZATIONNAME = "The Chromium Authors";
|
ORGANIZATIONNAME = "The Chromium Authors";
|
||||||
TargetAttributes = {
|
TargetAttributes = {
|
||||||
43AA89532444DA6500EDC39C = {
|
43AA89532444DA6500EDC39C = {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<Scheme
|
<Scheme
|
||||||
LastUpgradeVersion = "1510"
|
LastUpgradeVersion = "1620"
|
||||||
version = "1.7">
|
version = "1.7">
|
||||||
<BuildAction
|
<BuildAction
|
||||||
parallelizeBuildables = "YES"
|
parallelizeBuildables = "YES"
|
||||||
|
|
|
@ -146,6 +146,7 @@ func MissingArgumentError(message: String, details: Any?) -> FlutterError {
|
||||||
}
|
}
|
||||||
|
|
||||||
func listSites(result: @escaping FlutterResult) {
|
func listSites(result: @escaping FlutterResult) {
|
||||||
|
Task {
|
||||||
self.sites?.loadSites { (sites, err) -> () in
|
self.sites?.loadSites { (sites, err) -> () in
|
||||||
if (err != nil) {
|
if (err != nil) {
|
||||||
return result(CallFailedError(message: "Failed to load site list", details: err!.localizedDescription))
|
return result(CallFailedError(message: "Failed to load site list", details: err!.localizedDescription))
|
||||||
|
@ -158,6 +159,8 @@ func MissingArgumentError(message: String, details: Any?) -> FlutterError {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
func deleteSite(call: FlutterMethodCall, result: @escaping FlutterResult) {
|
func deleteSite(call: FlutterMethodCall, result: @escaping FlutterResult) {
|
||||||
guard let id = call.arguments as? String else { return result(NoArgumentsError()) }
|
guard let id = call.arguments as? String else { return result(NoArgumentsError()) }
|
||||||
//TODO: stop the site if its running currently
|
//TODO: stop the site if its running currently
|
||||||
|
|
|
@ -19,10 +19,11 @@ class Sites {
|
||||||
self.messenger = messenger
|
self.messenger = messenger
|
||||||
}
|
}
|
||||||
|
|
||||||
func loadSites(completion: @escaping ([String: Site]?, (any Error)?) -> ()) {
|
func loadSites() async -> Result<[String: Site], (any Error)> {
|
||||||
|
var result: Result<[String: Site], (any Error)>?;
|
||||||
_ = SiteList { (sites, err) in
|
_ = SiteList { (sites, err) in
|
||||||
if (err != nil) {
|
if (err != nil) {
|
||||||
return completion(nil, err)
|
result = Result.failure(err!)
|
||||||
}
|
}
|
||||||
|
|
||||||
sites?.values.forEach{ site in
|
sites?.values.forEach{ site in
|
||||||
|
@ -38,8 +39,10 @@ class Sites {
|
||||||
let justSites = self.containers.mapValues {
|
let justSites = self.containers.mapValues {
|
||||||
return $0.site
|
return $0.site
|
||||||
}
|
}
|
||||||
completion(justSites, nil)
|
result = Result.success(justSites)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return result!;
|
||||||
}
|
}
|
||||||
|
|
||||||
func deleteSite(id: String, callback: @escaping ((any Error)?) -> ()) {
|
func deleteSite(id: String, callback: @escaping ((any Error)?) -> ()) {
|
||||||
|
|
Loading…
Reference in a new issue