getEventIdList method

  1. @override
Future<List<String>> getEventIdList(
  1. Room room, {
  2. int start = 0,
  3. bool includeSending = false,
  4. int? limit,
})
override

Implementation

@override
Future<List<String>> getEventIdList(
  Room room, {
  int start = 0,
  bool includeSending = false,
  int? limit,
}) =>
    runBenchmarked<List<String>>('Get event id list', () async {
      // Get the synced event IDs from the store
      final timelineKey = TupleKey(room.id, '').toString();
      final timelineEventIds = List<String>.from(
          (await _timelineFragmentsBox.get(timelineKey)) ?? []);

      // Get the local stored SENDING events from the store
      late final List<String> sendingEventIds;
      if (!includeSending) {
        sendingEventIds = [];
      } else {
        final sendingTimelineKey = TupleKey(room.id, 'SENDING').toString();
        sendingEventIds = List<String>.from(
            (await _timelineFragmentsBox.get(sendingTimelineKey)) ?? []);
      }

      // Combine those two lists while respecting the start and limit parameters.
      // Create a new list object instead of concatonating list to prevent
      // random type errors.
      final eventIds = [
        ...sendingEventIds,
        ...timelineEventIds,
      ];
      if (limit != null && eventIds.length > limit) {
        eventIds.removeRange(limit, eventIds.length);
      }

      return eventIds;
    });