File tree Expand file tree Collapse file tree 2 files changed +30
-8
lines changed
Expand file tree Collapse file tree 2 files changed +30
-8
lines changed Original file line number Diff line number Diff line change @@ -7,4 +7,17 @@ class TimelineChunk {
77 List <Event > events;
88 TimelineChunk (
99 {required this .events, this .prevBatch = '' , this .nextBatch = '' });
10+
11+ @override
12+ bool operator == (Object other) {
13+ if (identical (this , other)) return true ;
14+ if (other is ! TimelineChunk ) return false ;
15+
16+ // Compare the lists of event ids regardless of order
17+ final thisEventIds = events.map ((e) => e.eventId).toSet ();
18+ final otherEventIds = other.events.map ((e) => e.eventId).toSet ();
19+
20+ return thisEventIds.length == otherEventIds.length &&
21+ thisEventIds.containsAll (otherEventIds);
22+ }
1023}
Original file line number Diff line number Diff line change @@ -1412,6 +1412,8 @@ class Room {
14121412 /// Is the room archived
14131413 bool get isArchived => membership == Membership .leave;
14141414
1415+ Timeline ? _timeline;
1416+
14151417 /// Creates a timeline from the store. Returns a [Timeline] object. If you
14161418 /// just want to update the whole timeline on every change, use the [onUpdate]
14171419 /// callback. For updating only the parts that have changed, use the
@@ -1460,14 +1462,21 @@ class Room {
14601462 }
14611463 }
14621464
1463- final timeline = Timeline (
1464- room: this ,
1465- chunk: chunk,
1466- onChange: onChange,
1467- onRemove: onRemove,
1468- onInsert: onInsert,
1469- onNewEvent: onNewEvent,
1470- onUpdate: onUpdate);
1465+ Timeline timeline;
1466+ if (_timeline != null && _timeline! .chunk == chunk) {
1467+ timeline = _timeline! ;
1468+ chunk = _timeline! .chunk;
1469+ } else {
1470+ timeline = Timeline (
1471+ room: this ,
1472+ chunk: chunk,
1473+ onChange: onChange,
1474+ onRemove: onRemove,
1475+ onInsert: onInsert,
1476+ onNewEvent: onNewEvent,
1477+ onUpdate: onUpdate);
1478+ _timeline = timeline;
1479+ }
14711480
14721481 // Fetch all users from database we have got here.
14731482 if (eventContextId == null ) {
You can’t perform that action at this time.
0 commit comments