mirror of
https://github.com/JGeek00/adguard-home-manager.git
synced 2025-04-22 14:59:12 +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 EncyptionValidation {
|
||||
class EncryptionValidation {
|
||||
final String? subject;
|
||||
final String? issuer;
|
||||
final String? keyType;
|
||||
|
@ -156,7 +163,7 @@ class EncyptionValidation {
|
|||
final String? privateKeyPath;
|
||||
final bool? privateKeySaved;
|
||||
|
||||
EncyptionValidation({
|
||||
EncryptionValidation({
|
||||
this.subject,
|
||||
this.issuer,
|
||||
this.keyType,
|
||||
|
@ -184,7 +191,7 @@ class EncyptionValidation {
|
|||
this.privateKeySaved,
|
||||
});
|
||||
|
||||
factory EncyptionValidation.fromJson(Map<String, dynamic> json) => EncyptionValidation(
|
||||
factory EncryptionValidation.fromJson(Map<String, dynamic> json) => EncryptionValidation(
|
||||
subject: json["subject"],
|
||||
issuer: json["issuer"],
|
||||
keyType: json["key_type"],
|
||||
|
|
|
@ -172,7 +172,7 @@ class _FiltersListState extends State<FiltersList> {
|
|||
loadStatus: widget.loadStatus,
|
||||
onRefresh: () async {
|
||||
final result = await filteringProvider.fetchFilters();
|
||||
if (result == false) {
|
||||
if (result == false && mounted) {
|
||||
showSnacbkar(
|
||||
appConfigProvider: appConfigProvider,
|
||||
label: AppLocalizations.of(context)!.errorLoadFilters,
|
||||
|
|
|
@ -72,7 +72,8 @@ class _EncryptionSettingsState extends State<EncryptionSettings> {
|
|||
String? validDataError;
|
||||
int certKeyValidApi = 0;
|
||||
|
||||
EncyptionValidation? certKeyValid;
|
||||
EncryptionValidation? certKeyValid;
|
||||
String? encryptionResultMessage;
|
||||
|
||||
bool formEdited = false;
|
||||
|
||||
|
@ -140,20 +141,27 @@ class _EncryptionSettingsState extends State<EncryptionSettings> {
|
|||
|
||||
if (!mounted) return;
|
||||
if (result.successful == true) {
|
||||
final data = result.content as EncyptionValidation;
|
||||
setState(() {
|
||||
if (data.warningValidation != null && data.warningValidation != '') {
|
||||
final data = result.content as EncryptionValidationResult;
|
||||
if (data.isObject == true) {
|
||||
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;
|
||||
validDataError = data.warningValidation;
|
||||
}
|
||||
else {
|
||||
certKeyValidApi = 1;
|
||||
validDataError = null;
|
||||
}
|
||||
certKeyValid = data;
|
||||
});
|
||||
}
|
||||
else {
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -253,11 +261,13 @@ class _EncryptionSettingsState extends State<EncryptionSettings> {
|
|||
centerTitle: false,
|
||||
actions: [
|
||||
IconButton(
|
||||
onPressed: certKeyValidApi == 2 && validDataError != null
|
||||
onPressed: certKeyValidApi == 2 && (validDataError != null || encryptionResultMessage != null)
|
||||
? () => {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => EncryptionErrorModal(error: validDataError!)
|
||||
builder: (context) => EncryptionErrorModal(
|
||||
error: validDataError ?? encryptionResultMessage ?? AppLocalizations.of(context)!.unknownError
|
||||
)
|
||||
)
|
||||
} : null,
|
||||
icon: generateStatus(context, appConfigProvider, localValidationValid, certKeyValidApi, formEdited),
|
||||
|
|
|
@ -698,9 +698,18 @@ class ApiClientV2 {
|
|||
try {
|
||||
return ApiResponse(
|
||||
successful: result.successful,
|
||||
content: result.body != null
|
||||
? EncyptionValidation.fromJson(jsonDecode(result.body!))
|
||||
: null
|
||||
content: result.body != null ? EncryptionValidationResult(
|
||||
isObject: false,
|
||||
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) {
|
||||
Sentry.captureException(e, stackTrace: stackTrace);
|
||||
|
|
Loading…
Add table
Reference in a new issue