Skip to content

Commit

Permalink
Refuse to link live timelines into the forwards/backwards position
Browse files Browse the repository at this point in the history
See element-hq/element-web#8593 (comment)

Previously (#873) we allowed half-linking timelines to each other if they satisfy the conditions, however this appears to not be helping. Instead, it seems like the timelines are getting stuck in a position where one direction is spliced but the other is broken. To avoid this case, we'll just avoid splicing in both directions when one of the directions is invalid.
  • Loading branch information
turt2live authored and bwindels committed Apr 8, 2019
1 parent 0ab4121 commit 963e271
Showing 1 changed file with 21 additions and 16 deletions.
37 changes: 21 additions & 16 deletions src/models/event-timeline-set.js
Original file line number Diff line number Diff line change
Expand Up @@ -413,26 +413,31 @@ EventTimelineSet.prototype.addEventsToTimeline = function(events, toStartOfTimel
const existingIsLive = existingTimeline === this._liveTimeline;
const timelineIsLive = timeline === this._liveTimeline;

if (direction === EventTimeline.BACKWARDS && existingIsLive) {
// The live timeline should never be spliced into a non-live position.
console.warn(
"Refusing to set a preceding existingTimeLine on our " +
"timeline as the existingTimeLine is live (" + existingTimeline + ")",
);
} else {
timeline.setNeighbouringTimeline(existingTimeline, direction);
}
const backwardsIsLive = direction === EventTimeline.BACKWARDS && existingIsLive;
const forwardsIsLive = direction === EventTimeline.FORWARDS && timelineIsLive;

if (inverseDirection === EventTimeline.BACKWARDS && timelineIsLive) {
if (backwardsIsLive || forwardsIsLive) {
// The live timeline should never be spliced into a non-live position.
console.warn(
"Refusing to set our preceding timeline on a existingTimeLine " +
"as our timeline is live (" + timeline + ")",
);
} else {
existingTimeline.setNeighbouringTimeline(timeline, inverseDirection);
// 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 + ")",
);
}
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
}

timeline.setNeighbouringTimeline(existingTimeline, direction);
existingTimeline.setNeighbouringTimeline(timeline, inverseDirection);

timeline = existingTimeline;
didUpdate = true;
}
Expand Down

0 comments on commit 963e271

Please sign in to comment.