verifiedContextNotes function

List<ContextNote> verifiedContextNotes({
  1. required Iterable<ContextNote> notes,
  2. required Bead workBead,
  3. required List<PriorArt> priorArt,
})

Keeps only context whose bead attribution can be checked at assembly time.

Implementation

List<ContextNote> verifiedContextNotes({
  required Iterable<ContextNote> notes,
  required Bead workBead,
  required List<PriorArt> priorArt,
}) {
  final knownIds = {workBead.id, for (final hit in priorArt) hit.beadId};
  return notes.where((note) {
    final citation = note.beadCitation;
    if (citation != null) {
      return verifiesBeadCitation(
        citation: citation,
        workBead: workBead,
        priorArt: priorArt,
      );
    }
    return !knownIds.any((id) => note.source.contains(id));
  }).toList();
}