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 = MultiKey(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 = MultiKey(room.id, 'SENDING').toString();
        sendingEventIds = List<String>.from(
            (await _timelineFragmentsBox.get(sendingTimelineKey)) ?? []);
      }

      // Combine those two lists while respecting the start and limit parameters.
      final eventIds = sendingEventIds + timelineEventIds;
      if (limit != null && eventIds.length > limit) {
        eventIds.removeRange(limit, eventIds.length);
      }

      return eventIds;
    });