2022-08-30 03:09:09 +00:00
|
|
|
part of 'server_jobs_cubit.dart';
|
|
|
|
|
|
|
|
class ServerJobsState extends ServerInstallationDependendState {
|
2022-09-18 20:12:09 +00:00
|
|
|
ServerJobsState({
|
|
|
|
final serverJobList = const <ServerJob>[],
|
2022-09-18 14:05:41 +00:00
|
|
|
this.migrationJobUid,
|
2022-09-18 20:12:09 +00:00
|
|
|
}) {
|
|
|
|
_serverJobList = serverJobList;
|
|
|
|
}
|
|
|
|
|
|
|
|
late final List<ServerJob> _serverJobList;
|
2022-09-18 14:05:41 +00:00
|
|
|
final String? migrationJobUid;
|
2022-08-30 03:09:09 +00:00
|
|
|
|
2022-09-19 00:21:08 +00:00
|
|
|
List<ServerJob> get serverJobList {
|
2022-09-20 09:42:20 +00:00
|
|
|
try {
|
|
|
|
final List<ServerJob> list = _serverJobList;
|
|
|
|
list.sort((final a, final b) => b.createdAt.compareTo(a.createdAt));
|
|
|
|
return list;
|
|
|
|
} on UnsupportedError {
|
|
|
|
return _serverJobList;
|
|
|
|
}
|
2022-09-19 00:21:08 +00:00
|
|
|
}
|
2022-09-18 20:12:09 +00:00
|
|
|
|
2022-09-19 00:42:00 +00:00
|
|
|
bool get hasRemovableJobs => serverJobList.any(
|
|
|
|
(final job) =>
|
|
|
|
job.status == JobStatusEnum.finished ||
|
|
|
|
job.status == JobStatusEnum.error,
|
|
|
|
);
|
|
|
|
|
2022-08-30 03:09:09 +00:00
|
|
|
@override
|
2022-09-19 00:42:00 +00:00
|
|
|
List<Object?> get props => [migrationJobUid, _serverJobList];
|
2022-08-30 03:09:09 +00:00
|
|
|
|
|
|
|
ServerJobsState copyWith({
|
|
|
|
final List<ServerJob>? serverJobList,
|
2022-09-18 14:05:41 +00:00
|
|
|
final String? migrationJobUid,
|
2022-08-30 03:09:09 +00:00
|
|
|
}) =>
|
|
|
|
ServerJobsState(
|
2022-09-18 20:12:09 +00:00
|
|
|
serverJobList: serverJobList ?? _serverJobList,
|
2022-09-18 14:05:41 +00:00
|
|
|
migrationJobUid: migrationJobUid ?? this.migrationJobUid,
|
2022-08-30 03:09:09 +00:00
|
|
|
);
|
|
|
|
}
|