1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-11-26 17:03:12 +03:00

Merge pull request #877 from matrix-org/travis/tlexpl-full-abort

Refuse to link live timelines into the forwards/backwards position when either is invalid
This commit is contained in:
Travis Ralston
2019-04-03 09:59:09 -06:00
committed by GitHub

View File

@@ -413,25 +413,30 @@ EventTimelineSet.prototype.addEventsToTimeline = function(events, toStartOfTimel
const existingIsLive = existingTimeline === this._liveTimeline;
const timelineIsLive = timeline === this._liveTimeline;
if (direction === EventTimeline.BACKWARDS && existingIsLive) {
const backwardsIsLive = direction === EventTimeline.BACKWARDS && existingIsLive;
const forwardsIsLive = direction === EventTimeline.FORWARDS && timelineIsLive;
if (backwardsIsLive || forwardsIsLive) {
// The live timeline should never be spliced into a non-live position.
// We use independent logging to better discover the problem at a glance.
console.warn({backwardsIsLive, forwardsIsLive}); // debugging
if (backwardsIsLive) {
console.warn(
"Refusing to set a preceding existingTimeLine on our " +
"timeline as the existingTimeLine is live (" + existingTimeline + ")",
);
} else {
timeline.setNeighbouringTimeline(existingTimeline, direction);
}
if (inverseDirection === EventTimeline.BACKWARDS && timelineIsLive) {
// The live timeline should never be spliced into a non-live position.
if (forwardsIsLive) {
console.warn(
"Refusing to set our preceding timeline on a existingTimeLine " +
"as our timeline is live (" + timeline + ")",
);
} else {
existingTimeline.setNeighbouringTimeline(timeline, inverseDirection);
}
continue; // abort splicing - try next event
}
timeline.setNeighbouringTimeline(existingTimeline, direction);
existingTimeline.setNeighbouringTimeline(timeline, inverseDirection);
timeline = existingTimeline;
didUpdate = true;