mirror of
https://github.com/JGeek00/adguard-home-manager.git
synced 2025-04-24 15:56:05 +00:00
Fix format exception getServerStatus
This commit is contained in:
parent
ccbe0cfd19
commit
791182d9c4
1 changed files with 20 additions and 14 deletions
|
@ -59,24 +59,30 @@ class ApiClientV2 {
|
||||||
HttpRequestClient.get(urlPath: "/parental/status", server: server),
|
HttpRequestClient.get(urlPath: "/parental/status", server: server),
|
||||||
HttpRequestClient.get(urlPath: "/clients", server: server),
|
HttpRequestClient.get(urlPath: "/clients", server: server),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if (
|
if (
|
||||||
results.map((e) => e.successful).every((e) => e == true) &&
|
results.map((e) => e.successful).every((e) => e == true) &&
|
||||||
results.map((e) => e.body).every((e) => e != null)
|
results.map((e) => e.body).every((e) => e != null)
|
||||||
) {
|
) {
|
||||||
final Map<String, dynamic> mappedData = {
|
try {
|
||||||
'stats': jsonDecode(results[0].body!),
|
final Map<String, dynamic> mappedData = {
|
||||||
'clients': jsonDecode(results[6].body!)['clients'],
|
'stats': jsonDecode(results[0].body!),
|
||||||
'status': jsonDecode(results[1].body!),
|
'clients': jsonDecode(results[6].body!)['clients'],
|
||||||
'filtering': jsonDecode(results[2].body!),
|
'status': jsonDecode(results[1].body!),
|
||||||
'safeSearch': jsonDecode(results[3].body!),
|
'filtering': jsonDecode(results[2].body!),
|
||||||
'safeBrowsingEnabled': jsonDecode(results[4].body!),
|
'safeSearch': jsonDecode(results[3].body!),
|
||||||
'parentalControlEnabled': jsonDecode(results[5].body!),
|
'safeBrowsingEnabled': jsonDecode(results[4].body!),
|
||||||
};
|
'parentalControlEnabled': jsonDecode(results[5].body!),
|
||||||
return ApiResponse(
|
};
|
||||||
successful: true,
|
return ApiResponse(
|
||||||
content: ServerStatus.fromJson(mappedData)
|
successful: true,
|
||||||
);
|
content: ServerStatus.fromJson(mappedData)
|
||||||
|
);
|
||||||
|
} on FormatException {
|
||||||
|
return const ApiResponse(successful: false);
|
||||||
|
} catch (e, stackTrace) {
|
||||||
|
Sentry.captureException(e, stackTrace: stackTrace);
|
||||||
|
return const ApiResponse(successful: false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return const ApiResponse(successful: false);
|
return const ApiResponse(successful: false);
|
||||||
|
|
Loading…
Add table
Reference in a new issue