Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refuse splicing the live timeline into a broken position #873

Merged
merged 4 commits into from
Mar 29, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 25 additions & 2 deletions src/models/event-timeline-set.js
Original file line number Diff line number Diff line change
Expand Up @@ -408,8 +408,31 @@ EventTimelineSet.prototype.addEventsToTimeline = function(events, toStartOfTimel
console.info("Already have timeline for " + eventId +
" - joining timeline " + timeline + " to " +
existingTimeline);
timeline.setNeighbouringTimeline(existingTimeline, direction);
existingTimeline.setNeighbouringTimeline(timeline, inverseDirection);

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the warnings are a bit cryptic here, to the point of being very confusing for the 2nd one. how about:

"Refusing to set a preceding existingTimeLine on our timeline as the existingTimeLine is live"
and
"Refusing to set our preceding timeline on a existingTimeLine as our timeline is live"
perhaps?

// Variables to keep the line length limited below.
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);
}

if (inverseDirection === EventTimeline.BACKWARDS && timelineIsLive) {
// 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);
}

timeline = existingTimeline;
didUpdate = true;
}
Expand Down