opt: more error catch on address book

This commit is contained in:
Kingtous 2022-09-19 10:22:40 +08:00
parent ef80dab48e
commit 910fb84857

View File

@ -45,8 +45,8 @@ class AbModel with ChangeNotifier {
} catch (err) {
abError = err.toString();
} finally {
notifyListeners();
abLoading = false;
notifyListeners();
}
return null;
}
@ -98,12 +98,18 @@ class AbModel with ChangeNotifier {
final body = jsonEncode({
"data": jsonEncode({"tags": tags, "peers": peers})
});
final resp =
await http.post(Uri.parse(api), headers: authHeaders, body: body);
abLoading = false;
await getAb();
try {
final resp =
await http.post(Uri.parse(api), headers: authHeaders, body: body);
abError = "";
await getAb();
debugPrint("resp: ${resp.body}");
} catch (e) {
abError = e.toString();
} finally {
abLoading = false;
}
notifyListeners();
debugPrint("resp: ${resp.body}");
}
bool idContainBy(String id) {