fix: Trigger onChange for index on aggregation event update

This commit is contained in:
Christian Pauly 2022-01-31 08:48:10 +01:00
parent ee1364db92
commit 48572f8f10
2 changed files with 9 additions and 1 deletions

View File

@ -1116,7 +1116,10 @@ class Room {
return;
}
/// Creates a timeline from the store. Returns a [Timeline] object.
/// Creates a timeline from the store. Returns a [Timeline] object. If you
/// just want to update the whole timeline on every change, use the [onUpdate]
/// callback. For updating only the parts that have changed, use the
/// [onChange], [onRemove] and the [onInsert] callbacks.
Future<Timeline> getTimeline({
void Function(int index)? onChange,
void Function(int index)? onRemove,

View File

@ -245,6 +245,10 @@ class Timeline {
_removeEventFromSet(events, event);
// add the new one
events.add(event);
if (onChange != null) {
final index = _findEvent(event_id: relationshipEventId);
onChange?.call(index);
}
}
void removeAggregatedEvent(Event event) {
@ -330,6 +334,7 @@ class Timeline {
}
addAggregatedEvent(newEvent);
onInsert?.call(index);
}
}