selfprivacy.org.app/lib/logic/cubit/services/services_state.dart

50 lines
1.2 KiB
Dart
Raw Normal View History

2021-08-29 09:50:24 +00:00
part of 'services_cubit.dart';
class ServicesState extends ServerInstallationDependendState {
2021-08-29 13:54:28 +00:00
const ServicesState({
required this.services,
2022-09-19 00:21:08 +00:00
required this.lockedServices,
2021-08-29 13:54:28 +00:00
});
2022-09-19 00:21:08 +00:00
const ServicesState.empty()
: this(services: const [], lockedServices: const []);
2021-08-29 13:54:28 +00:00
final List<Service> services;
2022-09-19 00:21:08 +00:00
final List<String> lockedServices;
List<Service> get servicesThatCanBeBackedUp => services
.where(
(final service) => service.canBeBackedUp,
)
.toList();
2022-09-19 00:21:08 +00:00
bool isServiceLocked(final String serviceId) =>
lockedServices.contains(serviceId);
Service? getServiceById(final String id) {
final service = services.firstWhere(
(final service) => service.id == id,
orElse: () => Service.empty,
);
if (service.id == 'empty') {
return null;
}
return service;
}
2021-08-29 09:50:24 +00:00
@override
2021-08-29 13:54:28 +00:00
List<Object> get props => [
services,
2022-09-19 00:21:08 +00:00
lockedServices,
2021-08-29 13:54:28 +00:00
];
2021-08-29 15:02:51 +00:00
2022-09-19 00:21:08 +00:00
ServicesState copyWith({
final List<Service>? services,
final List<String>? lockedServices,
}) =>
ServicesState(
services: services ?? this.services,
lockedServices: lockedServices ?? this.lockedServices,
);
2021-08-29 09:50:24 +00:00
}