getEventList method
Implementation
@override
Future<List<Event>> getEventList(
Room room, {
int start = 0,
bool onlySending = false,
int? limit,
}) =>
runBenchmarked<List<Event>>('Get event 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 sendingEventIds;
if (start != 0) {
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 end = min(timelineEventIds.length,
start + (limit ?? timelineEventIds.length));
final eventIds = List<String>.from(
[
...sendingEventIds,
...(start < timelineEventIds.length && !onlySending
? timelineEventIds.getRange(start, end).toList()
: [])
],
);
return await _getEventsByIds(eventIds, room);
});