removeEvent method

  1. @override
Future<void> removeEvent(
  1. String eventId,
  2. String roomId
)
override

Implementation

@override
Future<void> removeEvent(String eventId, String roomId) async {
  await _eventsBox.delete(TupleKey(roomId, eventId).toString());
  final keys = await _timelineFragmentsBox.getAllKeys();
  for (final key in keys) {
    final multiKey = TupleKey.fromString(key);
    if (multiKey.parts.first != roomId) continue;
    final eventIds =
        List<String>.from(await _timelineFragmentsBox.get(key) ?? []);
    final prevLength = eventIds.length;
    eventIds.removeWhere((id) => id == eventId);
    if (eventIds.length < prevLength) {
      await _timelineFragmentsBox.put(key, eventIds);
    }
  }
  return;
}