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

70 lines
1.8 KiB
Dart

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(
this.oldEntries,
this.newEntries,
this.meta,
this.loadingMore,
) : _lastCursor = newEntries.isEmpty ? '' : newEntries.first.cursor;
final List<ServerLogEntry> oldEntries;
final List<ServerLogEntry> newEntries;
final ServerLogsPageMeta meta;
final bool loadingMore;
final String _lastCursor;
List<String> get systemdUnits => oldEntries
.map((final entry) => entry.systemdUnit ?? 'kernel')
.toSet()
.toList();
List<ServerLogEntry> oldEntriesForUnit(final String unit) {
if (unit == 'kernel') {
final filteredEntries =
oldEntries.where((final entry) => entry.systemdUnit == null).toList();
return filteredEntries;
}
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;
}
@override
List<Object> get props => [oldEntries, newEntries, meta, _lastCursor];
}
final class ServerLogsError extends ServerLogsState {
const ServerLogsError(this.error);
final Object error;
@override
List<Object> get props => [error];
}