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 to link live timelines into the forwards/backwards position when either is invalid #877

Merged
merged 1 commit into from
Apr 3, 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
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
Copy link
Contributor

Choose a reason for hiding this comment

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

is this intended to stay in? Should be clear from seeing either of the below messages already?

Copy link
Member Author

@turt2live turt2live Apr 3, 2019

Choose a reason for hiding this comment

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

It's intended to stay in to make it slightly easier to troubleshoot from the logs without having to go hunting for messages in the code.

Edit: I'll add a note to clean it up

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