Merge branch 'nico/fix-null-events-in-legacy-db' into 'main'

fix: properly handle events not already in the hivedb

Closes famedly/app#1798

See merge request famedly/company/frontend/famedlysdk!1127
This commit is contained in:
Nicolas Werner 2022-09-12 09:09:08 +00:00
commit 7a9e5cbb85
1 changed files with 8 additions and 11 deletions

View File

@ -374,17 +374,14 @@ class FamedlySdkHiveDatabase extends DatabaseApi {
}
/// Loads a whole list of events at once from the store for a specific room
Future<List<Event>> _getEventsByIds(List<String> eventIds, Room room) =>
Future.wait(eventIds
.map(
(eventId) async => Event.fromJson(
convertToJson(
await _eventsBox.get(MultiKey(room.id, eventId).toString()),
),
room,
),
)
.toList());
Future<List<Event>> _getEventsByIds(List<String> eventIds, Room room) async {
final events = await Future.wait(eventIds.map((String eventId) async {
final entry = await _eventsBox.get(MultiKey(room.id, eventId).toString());
return entry is Map ? Event.fromJson(convertToJson(entry), room) : null;
}));
return events.whereType<Event>().toList();
}
@override
Future<List<Event>> getEventList(