fetchByStates method

  1. @override
Future<TrackerResult<List<Issue>>> fetchByStates(
  1. List<String> stateNames
)
override

Returns issues currently in any of the supplied stateNames.

Used by startup terminal-workspace cleanup. An empty input list MUST short-circuit with an empty success result without making a network call.

Implementation

@override
Future<TrackerResult<List<Issue>>> fetchByStates(
  List<String> stateNames,
) async {
  if (stateNames.isEmpty) {
    return const TrackerSuccess<List<Issue>>(<Issue>[]);
  }

  final result = await _loadAllIssues();
  return result.fold(TrackerError<List<Issue>>.new, (issues) {
    final wanted = stateNames.map((s) => s.toLowerCase()).toSet();
    final filtered = issues
        .where((i) => wanted.contains(i.normalizedState))
        .toList(growable: false);
    return TrackerSuccess<List<Issue>>(filtered);
  });
}