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 /// 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<List<Event>> _getEventsByIds(List<String> eventIds, Room room) async {
Future.wait(eventIds final events = await Future.wait(eventIds.map((String eventId) async {
.map( final entry = await _eventsBox.get(MultiKey(room.id, eventId).toString());
(eventId) async => Event.fromJson( return entry is Map ? Event.fromJson(convertToJson(entry), room) : null;
convertToJson( }));
await _eventsBox.get(MultiKey(room.id, eventId).toString()),
), return events.whereType<Event>().toList();
room, }
),
)
.toList());
@override @override
Future<List<Event>> getEventList( Future<List<Event>> getEventList(