selfprivacy.org.app/lib/logic/cubit/jobs/jobs_state.dart

35 lines
924 B
Dart
Raw Normal View History

2021-05-26 00:53:54 +03:00
part of 'jobs_cubit.dart';
2021-07-29 08:24:42 +03:00
abstract class JobsState extends Equatable {
const JobsState(this.serverJobList);
final List<ServerJob> serverJobList;
2021-07-29 08:24:42 +03:00
@override
List<Object?> get props => [serverJobList];
2021-07-29 08:24:42 +03:00
}
2021-05-26 00:53:54 +03:00
class JobsStateLoading extends JobsState {
const JobsStateLoading(super.serverJobList);
}
2021-05-26 00:53:54 +03:00
class JobsStateEmpty extends JobsState {
const JobsStateEmpty(super.serverJobList);
}
2021-05-26 00:53:54 +03:00
2021-07-29 08:24:42 +03:00
class JobsStateWithJobs extends JobsState {
const JobsStateWithJobs(this.clientJobList, super.serverJobList);
final List<ClientJob> clientJobList;
2021-05-26 00:53:54 +03:00
2022-06-05 22:36:32 +03:00
JobsState removeById(final String id) {
final List<ClientJob> newJobsList =
clientJobList.where((final element) => element.id != id).toList();
2021-07-29 08:24:42 +03:00
if (newJobsList.isEmpty) {
return JobsStateEmpty(serverJobList);
2021-07-29 08:24:42 +03:00
}
return JobsStateWithJobs(newJobsList, serverJobList);
2021-05-26 00:53:54 +03:00
}
@override
List<Object?> get props => [...super.props, clientJobList];
2021-05-26 00:53:54 +03:00
}