Merge pull request #1530 from Kingtous/master
fix: add null catch on address book request
This commit is contained in:
commit
ab60db3e66
@ -414,7 +414,7 @@ class _ConnectionPageState extends State<ConnectionPage> {
|
|||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
if (model.abLoading) {
|
if (model.abLoading) {
|
||||||
return Center(
|
return const Center(
|
||||||
child: CircularProgressIndicator(),
|
child: CircularProgressIndicator(),
|
||||||
);
|
);
|
||||||
} else if (model.abError.isNotEmpty) {
|
} else if (model.abError.isNotEmpty) {
|
||||||
|
@ -266,7 +266,7 @@ class AddressBookPeerWidget extends BasePeerWidget {
|
|||||||
loadEvent: 'load_address_book_peers',
|
loadEvent: 'load_address_book_peers',
|
||||||
offstageFunc: (Peer peer) =>
|
offstageFunc: (Peer peer) =>
|
||||||
!_hitTag(gFFI.abModel.selectedTags, peer.tags),
|
!_hitTag(gFFI.abModel.selectedTags, peer.tags),
|
||||||
peerCardWidgetFunc: (Peer peer) => DiscoveredPeerCard(
|
peerCardWidgetFunc: (Peer peer) => AddressBookPeerCard(
|
||||||
peer: peer,
|
peer: peer,
|
||||||
),
|
),
|
||||||
initPeers: _loadPeers(),
|
initPeers: _loadPeers(),
|
||||||
|
@ -28,21 +28,26 @@ class AbModel with ChangeNotifier {
|
|||||||
try {
|
try {
|
||||||
final resp =
|
final resp =
|
||||||
await http.post(Uri.parse(api), headers: await _getHeaders());
|
await http.post(Uri.parse(api), headers: await _getHeaders());
|
||||||
Map<String, dynamic> json = jsonDecode(resp.body);
|
if (resp.body.isNotEmpty && resp.body.toLowerCase() != "null") {
|
||||||
if (json.containsKey('error')) {
|
Map<String, dynamic> json = jsonDecode(resp.body);
|
||||||
abError = json['error'];
|
if (json.containsKey('error')) {
|
||||||
} else if (json.containsKey('data')) {
|
abError = json['error'];
|
||||||
final data = jsonDecode(json['data']);
|
} else if (json.containsKey('data')) {
|
||||||
tags.value = data['tags'];
|
final data = jsonDecode(json['data']);
|
||||||
peers.value = data['peers'];
|
tags.value = data['tags'];
|
||||||
|
peers.value = data['peers'];
|
||||||
|
}
|
||||||
|
notifyListeners();
|
||||||
|
return resp.body;
|
||||||
|
} else {
|
||||||
|
return "";
|
||||||
}
|
}
|
||||||
return resp.body;
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
abError = err.toString();
|
abError = err.toString();
|
||||||
} finally {
|
} finally {
|
||||||
|
notifyListeners();
|
||||||
abLoading = false;
|
abLoading = false;
|
||||||
}
|
}
|
||||||
notifyListeners();
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,7 +65,6 @@ class AbModel with ChangeNotifier {
|
|||||||
return _ffi?.getHttpHeaders();
|
return _ffi?.getHttpHeaders();
|
||||||
}
|
}
|
||||||
|
|
||||||
///
|
|
||||||
void addId(String id) async {
|
void addId(String id) async {
|
||||||
if (idContainBy(id)) {
|
if (idContainBy(id)) {
|
||||||
return;
|
return;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user