You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-11-26 17:03:12 +03:00
EventTimeline: Fix baseIndex after removing the last event
Removing the last event in an EventTimeline (as we might, for instance, if it was a local echo in an empty timeline) got us into a state where the baseIndex would increment when adding events to the end of the timeline, causing much confusion.
This commit is contained in:
@@ -31,7 +31,7 @@ var MatrixEvent = require("./event").MatrixEvent;
|
||||
function EventTimeline(roomId) {
|
||||
this._roomId = roomId;
|
||||
this._events = [];
|
||||
this._baseIndex = -1;
|
||||
this._baseIndex = 0;
|
||||
this._startState = new RoomState(roomId);
|
||||
this._startState.paginationToken = null;
|
||||
this._endState = new RoomState(roomId);
|
||||
@@ -252,7 +252,7 @@ EventTimeline.prototype.addEvent = function(event, atStart, spliceBeforeLocalEch
|
||||
}
|
||||
|
||||
this._events.splice(insertIndex, 0, event); // insert element
|
||||
if (insertIndex <= this._baseIndex || this._baseIndex == -1) {
|
||||
if (atStart) {
|
||||
this._baseIndex++;
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user