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