You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-11-28 05:03:59 +03:00
don't double-add events in Room.addEventsToTimeline
also, ignore notif events from initialSync as their time ordering is wrong
This commit is contained in:
@@ -1792,7 +1792,8 @@ MatrixClient.prototype.paginateEventTimeline = function(eventTimeline, opts) {
|
|||||||
).then(function(res) {
|
).then(function(res) {
|
||||||
var token = res.end;
|
var token = res.end;
|
||||||
var matrixEvents = utils.map(res.chunk, self.getEventMapper());
|
var matrixEvents = utils.map(res.chunk, self.getEventMapper());
|
||||||
room.addEventsToTimeline(matrixEvents, backwards, eventTimeline, token);
|
eventTimeline.getTimelineSet()
|
||||||
|
.addEventsToTimeline(matrixEvents, backwards, eventTimeline, token);
|
||||||
|
|
||||||
// if we've hit the end of the timeline, we need to stop trying to
|
// if we've hit the end of the timeline, we need to stop trying to
|
||||||
// paginate. We need to keep the 'forwards' token though, to make sure
|
// paginate. We need to keep the 'forwards' token though, to make sure
|
||||||
|
|||||||
@@ -389,12 +389,10 @@ Room.prototype.getCanonicalAlias = function() {
|
|||||||
*/
|
*/
|
||||||
Room.prototype.addEventsToTimeline = function(events, toStartOfTimeline,
|
Room.prototype.addEventsToTimeline = function(events, toStartOfTimeline,
|
||||||
timeline, paginationToken) {
|
timeline, paginationToken) {
|
||||||
for (var i = 0; i < this._timelineSets.length; i++) {
|
timeline.getTimelineSet().addEventsToTimeline(
|
||||||
this._timelineSets[i].addEventsToTimeline(
|
|
||||||
events, toStartOfTimeline,
|
events, toStartOfTimeline,
|
||||||
timeline, paginationToken
|
timeline, paginationToken
|
||||||
);
|
);
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -808,8 +808,12 @@ SyncApi.prototype._processSyncResponse = function(syncToken, data) {
|
|||||||
accountDataEvents.forEach(function(e) { client.emit("event", e); });
|
accountDataEvents.forEach(function(e) { client.emit("event", e); });
|
||||||
});
|
});
|
||||||
|
|
||||||
// update the notification timeline, if appropriate
|
// update the notification timeline, if appropriate.
|
||||||
if (this._notifEvents.length) {
|
// we only do this for live events, as otherwise we can't order them sanely
|
||||||
|
// in the timeline relative to ones paginated in by /notifications.
|
||||||
|
// XXX: we could fix this by making EventTimeline support chronological
|
||||||
|
// ordering... but it doesn't, right now.
|
||||||
|
if (syncToken && this._notifEvents.length) {
|
||||||
this._notifEvents.sort(function(a, b) {
|
this._notifEvents.sort(function(a, b) {
|
||||||
return a.getTs() - b.getTs();
|
return a.getTs() - b.getTs();
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user