refactor: from review

This commit is contained in:
dettlaff 2024-10-10 20:12:12 +04:00 committed by Inex Code
parent 142249adec
commit 8aacee7c9c
2 changed files with 12 additions and 10 deletions

View file

@ -10,7 +10,6 @@ class DesiredDnsRecord {
required this.content,
this.type = 'A',
this.description = '',
this.category = DnsRecordsCategory.services,
this.isSatisfied = false,
this.displayName,
});
@ -20,16 +19,25 @@ class DesiredDnsRecord {
final String content;
final String description;
final String? displayName;
final DnsRecordsCategory category;
final bool isSatisfied;
DnsRecordsCategory get category {
switch (type) {
case 'A':
return DnsRecordsCategory.services;
case 'CAA':
return DnsRecordsCategory.other;
default:
return DnsRecordsCategory.email;
}
}
DesiredDnsRecord copyWith({
final String? name,
final String? type,
final String? content,
final String? description,
final String? displayName,
final DnsRecordsCategory? category,
final bool? isSatisfied,
}) =>
DesiredDnsRecord(
@ -37,7 +45,6 @@ class DesiredDnsRecord {
type: type ?? this.type,
content: content ?? this.content,
description: description ?? this.description,
category: category ?? this.category,
isSatisfied: isSatisfied ?? this.isSatisfied,
displayName: displayName ?? this.displayName,
);

View file

@ -122,7 +122,6 @@ class DnsRecordsCubit extends ServerConnectionDependentCubit<DnsRecordsState> {
content: pendingDnsRecord.content!,
isSatisfied: isSatisfied,
type: pendingDnsRecord.type,
category: DnsRecordsCategory.email,
),
);
} else {
@ -138,11 +137,7 @@ class DnsRecordsCubit extends ServerConnectionDependentCubit<DnsRecordsState> {
displayName: pendingDnsRecord.displayName,
content: pendingDnsRecord.content!,
isSatisfied: foundMatch,
category: pendingDnsRecord.type == 'A'
? DnsRecordsCategory.services
: (pendingDnsRecord.type == 'CAA'
? DnsRecordsCategory.other
: DnsRecordsCategory.email),
type: pendingDnsRecord.type,
),
);
}