diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index dc67473e..cf47ca08 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -88,7 +88,7 @@ code_quality: stage: coverage image: google/dart before_script: - - dart pub global activate dart_code_metrics + - dart pub global activate dart_code_metrics 4.4.0 script: - dart pub global run dart_code_metrics:metrics lib -r gitlab > code-quality-report.json artifacts: 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); } } diff --git a/pubspec.yaml b/pubspec.yaml index aba229f6..4b2522ca 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -31,7 +31,7 @@ dependencies: fluffybox: ^0.4.2 dev_dependencies: - dart_code_metrics: ^4.4.0 + dart_code_metrics: 4.4.0 # Pinned because of https://github.com/dart-code-checker/dart-code-metrics/issues/674 pedantic: ^1.11.0 test: ^1.15.7 coverage: ">=0.15.0 <2.0.0"