mirror of
https://github.com/JGeek00/adguard-home-manager.git
synced 2025-06-06 06:40:20 +00:00
Bug fixes
This commit is contained in:
parent
002fca4e3f
commit
8dc9539a3a
4 changed files with 52 additions and 26 deletions
|
@ -124,12 +124,19 @@ class EncryptionData {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class EncryptionValidationResult {
|
||||||
|
final bool isObject;
|
||||||
|
final EncryptionValidation? encryptionValidation;
|
||||||
|
final String? message;
|
||||||
|
|
||||||
EncyptionValidation encyptionValidationFromJson(String str) => EncyptionValidation.fromJson(json.decode(str));
|
const EncryptionValidationResult({
|
||||||
|
required this.isObject,
|
||||||
|
this.encryptionValidation,
|
||||||
|
this.message
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
String encyptionValidationToJson(EncyptionValidation data) => json.encode(data.toJson());
|
class EncryptionValidation {
|
||||||
|
|
||||||
class EncyptionValidation {
|
|
||||||
final String? subject;
|
final String? subject;
|
||||||
final String? issuer;
|
final String? issuer;
|
||||||
final String? keyType;
|
final String? keyType;
|
||||||
|
@ -156,7 +163,7 @@ class EncyptionValidation {
|
||||||
final String? privateKeyPath;
|
final String? privateKeyPath;
|
||||||
final bool? privateKeySaved;
|
final bool? privateKeySaved;
|
||||||
|
|
||||||
EncyptionValidation({
|
EncryptionValidation({
|
||||||
this.subject,
|
this.subject,
|
||||||
this.issuer,
|
this.issuer,
|
||||||
this.keyType,
|
this.keyType,
|
||||||
|
@ -184,7 +191,7 @@ class EncyptionValidation {
|
||||||
this.privateKeySaved,
|
this.privateKeySaved,
|
||||||
});
|
});
|
||||||
|
|
||||||
factory EncyptionValidation.fromJson(Map<String, dynamic> json) => EncyptionValidation(
|
factory EncryptionValidation.fromJson(Map<String, dynamic> json) => EncryptionValidation(
|
||||||
subject: json["subject"],
|
subject: json["subject"],
|
||||||
issuer: json["issuer"],
|
issuer: json["issuer"],
|
||||||
keyType: json["key_type"],
|
keyType: json["key_type"],
|
||||||
|
|
|
@ -172,7 +172,7 @@ class _FiltersListState extends State<FiltersList> {
|
||||||
loadStatus: widget.loadStatus,
|
loadStatus: widget.loadStatus,
|
||||||
onRefresh: () async {
|
onRefresh: () async {
|
||||||
final result = await filteringProvider.fetchFilters();
|
final result = await filteringProvider.fetchFilters();
|
||||||
if (result == false) {
|
if (result == false && mounted) {
|
||||||
showSnacbkar(
|
showSnacbkar(
|
||||||
appConfigProvider: appConfigProvider,
|
appConfigProvider: appConfigProvider,
|
||||||
label: AppLocalizations.of(context)!.errorLoadFilters,
|
label: AppLocalizations.of(context)!.errorLoadFilters,
|
||||||
|
|
|
@ -72,7 +72,8 @@ class _EncryptionSettingsState extends State<EncryptionSettings> {
|
||||||
String? validDataError;
|
String? validDataError;
|
||||||
int certKeyValidApi = 0;
|
int certKeyValidApi = 0;
|
||||||
|
|
||||||
EncyptionValidation? certKeyValid;
|
EncryptionValidation? certKeyValid;
|
||||||
|
String? encryptionResultMessage;
|
||||||
|
|
||||||
bool formEdited = false;
|
bool formEdited = false;
|
||||||
|
|
||||||
|
@ -140,20 +141,27 @@ class _EncryptionSettingsState extends State<EncryptionSettings> {
|
||||||
|
|
||||||
if (!mounted) return;
|
if (!mounted) return;
|
||||||
if (result.successful == true) {
|
if (result.successful == true) {
|
||||||
final data = result.content as EncyptionValidation;
|
final data = result.content as EncryptionValidationResult;
|
||||||
setState(() {
|
if (data.isObject == true) {
|
||||||
if (data.warningValidation != null && data.warningValidation != '') {
|
final object = data.encryptionValidation!;
|
||||||
|
setState(() {
|
||||||
|
if (object.warningValidation != null && object.warningValidation != '') {
|
||||||
|
certKeyValidApi = 2;
|
||||||
|
validDataError = object.warningValidation;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
certKeyValidApi = 1;
|
||||||
|
validDataError = null;
|
||||||
|
}
|
||||||
|
certKeyValid = object;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
setState(() {
|
||||||
|
encryptionResultMessage = data.message;
|
||||||
certKeyValidApi = 2;
|
certKeyValidApi = 2;
|
||||||
validDataError = data.warningValidation;
|
});
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
certKeyValidApi = 1;
|
|
||||||
validDataError = null;
|
|
||||||
}
|
|
||||||
certKeyValid = data;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -253,11 +261,13 @@ class _EncryptionSettingsState extends State<EncryptionSettings> {
|
||||||
centerTitle: false,
|
centerTitle: false,
|
||||||
actions: [
|
actions: [
|
||||||
IconButton(
|
IconButton(
|
||||||
onPressed: certKeyValidApi == 2 && validDataError != null
|
onPressed: certKeyValidApi == 2 && (validDataError != null || encryptionResultMessage != null)
|
||||||
? () => {
|
? () => {
|
||||||
showDialog(
|
showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (context) => EncryptionErrorModal(error: validDataError!)
|
builder: (context) => EncryptionErrorModal(
|
||||||
|
error: validDataError ?? encryptionResultMessage ?? AppLocalizations.of(context)!.unknownError
|
||||||
|
)
|
||||||
)
|
)
|
||||||
} : null,
|
} : null,
|
||||||
icon: generateStatus(context, appConfigProvider, localValidationValid, certKeyValidApi, formEdited),
|
icon: generateStatus(context, appConfigProvider, localValidationValid, certKeyValidApi, formEdited),
|
||||||
|
|
|
@ -698,9 +698,18 @@ class ApiClientV2 {
|
||||||
try {
|
try {
|
||||||
return ApiResponse(
|
return ApiResponse(
|
||||||
successful: result.successful,
|
successful: result.successful,
|
||||||
content: result.body != null
|
content: result.body != null ? EncryptionValidationResult(
|
||||||
? EncyptionValidation.fromJson(jsonDecode(result.body!))
|
isObject: false,
|
||||||
: null
|
encryptionValidation: EncryptionValidation.fromJson(jsonDecode(result.body!))
|
||||||
|
) : null
|
||||||
|
);
|
||||||
|
} on FormatException {
|
||||||
|
return ApiResponse(
|
||||||
|
successful: result.successful,
|
||||||
|
content: result.body != null ? EncryptionValidationResult(
|
||||||
|
isObject: false,
|
||||||
|
message: result.body
|
||||||
|
) : null
|
||||||
);
|
);
|
||||||
} catch (e, stackTrace) {
|
} catch (e, stackTrace) {
|
||||||
Sentry.captureException(e, stackTrace: stackTrace);
|
Sentry.captureException(e, stackTrace: stackTrace);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue