selfprivacy.org.app/lib/logic/bloc/server_logs/server_logs_state.dart

72 lines
1.9 KiB
Dart
Raw Normal View History

2024-07-24 14:22:12 +00:00
part of 'server_logs_bloc.dart';
sealed class ServerLogsState extends Equatable {
const ServerLogsState();
}
final class ServerLogsInitial extends ServerLogsState {
@override
List<Object> get props => [];
}
final class ServerLogsLoading extends ServerLogsState {
@override
List<Object> get props => [];
}
final class ServerLogsLoaded extends ServerLogsState {
ServerLogsLoaded({
required this.oldEntries,
required this.newEntries,
required this.meta,
required this.loadingMore,
this.slice,
}) : _lastCursor = newEntries.isEmpty ? '' : newEntries.first.cursor;
2024-07-24 14:22:12 +00:00
final List<ServerLogEntry> oldEntries;
final List<ServerLogEntry> newEntries;
2024-07-24 14:22:12 +00:00
final ServerLogsPageMeta meta;
final bool loadingMore;
final String _lastCursor;
final String? slice;
2024-07-24 14:22:12 +00:00
List<String> get systemdUnits => oldEntries
2024-07-24 14:22:12 +00:00
.map((final entry) => entry.systemdUnit ?? 'kernel')
.toSet()
.toList();
List<ServerLogEntry> oldEntriesForUnit(final String unit) {
2024-07-24 14:22:12 +00:00
if (unit == 'kernel') {
final filteredEntries =
oldEntries.where((final entry) => entry.systemdUnit == null).toList();
return filteredEntries;
2024-07-24 14:22:12 +00:00
}
final filteredEntries =
oldEntries.where((final entry) => entry.systemdUnit == unit).toList();
return filteredEntries;
}
List<ServerLogEntry> newEntriesForUnit(final String unit) {
if (unit == 'kernel') {
final filteredEntries =
newEntries.where((final entry) => entry.systemdUnit == null).toList();
return filteredEntries;
}
final filteredEntries =
newEntries.where((final entry) => entry.systemdUnit == unit).toList();
return filteredEntries;
2024-07-24 14:22:12 +00:00
}
@override
List<Object?> get props => [oldEntries, newEntries, meta, _lastCursor, slice];
2024-07-24 14:22:12 +00:00
}
final class ServerLogsError extends ServerLogsState {
const ServerLogsError(this.error);
final Object error;
@override
List<Object> get props => [error];
}