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