2021-08-29 09:50:24 +00:00
|
|
|
part of 'services_cubit.dart';
|
|
|
|
|
2022-05-17 13:31:34 +00:00
|
|
|
class ServicesState extends ServerInstallationDependendState {
|
2021-08-29 13:54:28 +00:00
|
|
|
const ServicesState({
|
2022-08-29 20:35:06 +00:00
|
|
|
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
|
|
|
|
2022-08-29 20:35:06 +00:00
|
|
|
final List<Service> services;
|
2022-09-19 00:21:08 +00:00
|
|
|
final List<String> lockedServices;
|
|
|
|
|
2023-06-29 10:52:25 +00:00
|
|
|
List<Service> get servicesThatCanBeBackedUp => services
|
|
|
|
.where(
|
2023-06-29 10:51:38 +00:00
|
|
|
(final service) => service.canBeBackedUp,
|
2023-06-29 10:52:25 +00:00
|
|
|
)
|
|
|
|
.toList();
|
2023-06-29 10:51:38 +00:00
|
|
|
|
2022-09-19 00:21:08 +00:00
|
|
|
bool isServiceLocked(final String serviceId) =>
|
|
|
|
lockedServices.contains(serviceId);
|
|
|
|
|
2022-08-29 20:35:06 +00:00
|
|
|
Service? getServiceById(final String id) {
|
2022-09-05 10:51:01 +00:00
|
|
|
final service = services.firstWhere(
|
|
|
|
(final service) => service.id == id,
|
|
|
|
orElse: () => Service.empty,
|
|
|
|
);
|
2022-08-29 20:35:06 +00:00
|
|
|
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 => [
|
2022-08-29 20:35:06 +00:00
|
|
|
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
|
|
|
}
|