loadEvents method

  1. @override
Future<List<Nip01Event>> loadEvents({
  1. List<String>? pubKeys,
  2. List<int>? kinds,
  3. String? pTag,
  4. int? since,
  5. int? until,
})
override

Implementation

@override
Future<List<Nip01Event>> loadEvents({
  List<String>? pubKeys,
  List<int>? kinds,
  String? pTag,
  int? since,
  int? until,
}) async {
  if (since != null || until != null) {
    throw Exception("since | until not implemented");
  }
  List<Nip01Event> events = isar_ds.isar.dbEvents
      .where()
      .optional(kinds != null && kinds.isNotEmpty,
          (q) => q.anyOf(kinds!, (q, kind) => q.kindEqualTo(kind)))
      .and()
      .optional(pubKeys != null && pubKeys.isNotEmpty,
          (q) => q.anyOf(pubKeys!, (q, pubKey) => q.pubKeyEqualTo(pubKey)))
      // .and()
      // .optional(Helpers.isNotBlank(pTag), (q) => q.pTagsElementEqualTo(pTag!))
      .findAll();
  events = Helpers.isNotBlank(pTag)
      ? events.where((event) => event.pTags.contains(pTag)).toList()
      : events;
  return eventFilter != null
      ? events.where((event) => eventFilter!.filter(event)).toList()
      : events;
}