diff --git a/lib/src/room.dart b/lib/src/room.dart index 67378580..ef796dd5 100644 --- a/lib/src/room.dart +++ b/lib/src/room.dart @@ -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 getTimeline({ void Function(int index)? onChange, void Function(int index)? onRemove, diff --git a/lib/src/timeline.dart b/lib/src/timeline.dart index 104462f5..4232dcf4 100644 --- a/lib/src/timeline.dart +++ b/lib/src/timeline.dart @@ -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); } }