fix: Trigger onChange for index on aggregation event update
This commit is contained in:
		
							parent
							
								
									ee1364db92
								
							
						
					
					
						commit
						48572f8f10
					
				|  | @ -1116,7 +1116,10 @@ class Room { | ||||||
|     return; |     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({ |   Future<Timeline> getTimeline({ | ||||||
|     void Function(int index)? onChange, |     void Function(int index)? onChange, | ||||||
|     void Function(int index)? onRemove, |     void Function(int index)? onRemove, | ||||||
|  |  | ||||||
|  | @ -245,6 +245,10 @@ class Timeline { | ||||||
|     _removeEventFromSet(events, event); |     _removeEventFromSet(events, event); | ||||||
|     // add the new one |     // add the new one | ||||||
|     events.add(event); |     events.add(event); | ||||||
|  |     if (onChange != null) { | ||||||
|  |       final index = _findEvent(event_id: relationshipEventId); | ||||||
|  |       onChange?.call(index); | ||||||
|  |     } | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   void removeAggregatedEvent(Event event) { |   void removeAggregatedEvent(Event event) { | ||||||
|  | @ -330,6 +334,7 @@ class Timeline { | ||||||
|           } |           } | ||||||
| 
 | 
 | ||||||
|           addAggregatedEvent(newEvent); |           addAggregatedEvent(newEvent); | ||||||
|  | 
 | ||||||
|           onInsert?.call(index); |           onInsert?.call(index); | ||||||
|         } |         } | ||||||
|       } |       } | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue