refactor(services): Remove unused state getters

This commit is contained in:
Inex Code 2023-06-29 13:52:25 +03:00
parent 90ab4244f6
commit 7f5488c76b

View file

@ -12,44 +12,15 @@ class ServicesState extends ServerInstallationDependendState {
final List<Service> services;
final List<String> lockedServices;
List<Service> get servicesThatCanBeBackedUp => services.where(
List<Service> get servicesThatCanBeBackedUp => services
.where(
(final service) => service.canBeBackedUp,
).toList();
)
.toList();
bool isServiceLocked(final String serviceId) =>
lockedServices.contains(serviceId);
bool get isPasswordManagerEnable => services
.firstWhere(
(final service) => service.id == 'bitwarden',
orElse: () => Service.empty,
)
.isEnabled;
bool get isCloudEnable => services
.firstWhere(
(final service) => service.id == 'nextcloud',
orElse: () => Service.empty,
)
.isEnabled;
bool get isGitEnable => services
.firstWhere(
(final service) => service.id == 'gitea',
orElse: () => Service.empty,
)
.isEnabled;
bool get isSocialNetworkEnable => services
.firstWhere(
(final service) => service.id == 'pleroma',
orElse: () => Service.empty,
)
.isEnabled;
bool get isVpnEnable => services
.firstWhere(
(final service) => service.id == 'ocserv',
orElse: () => Service.empty,
)
.isEnabled;
Service? getServiceById(final String id) {
final service = services.firstWhere(
(final service) => service.id == id,
@ -67,23 +38,6 @@ class ServicesState extends ServerInstallationDependendState {
lockedServices,
];
bool isEnableByType(final Service service) {
switch (service.id) {
case 'bitwarden':
return isPasswordManagerEnable;
case 'nextcloud':
return isCloudEnable;
case 'pleroma':
return isSocialNetworkEnable;
case 'gitea':
return isGitEnable;
case 'ocserv':
return isVpnEnable;
default:
throw Exception('wrong state');
}
}
ServicesState copyWith({
final List<Service>? services,
final List<String>? lockedServices,