Merge branch 'krille/update-on-aggregation-event' into 'main'

fix: Trigger onChange for index on aggregation event update

See merge request famedly/company/frontend/famedlysdk!945
This commit is contained in:
Nicolas Werner 2022-02-01 14:22:50 +00:00
commit de38ddbbe1
4 changed files with 11 additions and 3 deletions

View File

@ -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:

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);
}
}

View File

@ -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"