fix: missing range check

When requesting history the `start` parameter could become larger than the loaded events
from the database were, resulting in an error when attempting to request history.
This commit is contained in:
Sorunome 2021-09-30 14:34:28 +02:00
parent 1d0202e14e
commit 259c9cade6
No known key found for this signature in database
GPG Key ID: B19471D07FC9BE9C
1 changed files with 4 additions and 2 deletions

View File

@ -389,8 +389,10 @@ class FamedlySdkHiveDatabase extends DatabaseApi {
// Combine those two lists while respecting the start and limit parameters.
final end = min(
timelineEventIds.length, start + (limit ?? timelineEventIds.length));
final eventIds =
sendingEventIds + timelineEventIds.getRange(start, end).toList();
final eventIds = sendingEventIds +
(start < timelineEventIds.length
? timelineEventIds.getRange(start, end).toList()
: []);
return await _getEventsByIds(eventIds.cast<String>(), room);
}