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

Fix to avoid duplicate chapters by building a new list each time #3354

Closed
wants to merge 9 commits into from

Conversation

vdeshpande
Copy link
Contributor

@vdeshpande vdeshpande commented Jun 1, 2016

Description

Duplicate chapters list gets added to the existing chapters item list whenever we try adding a chapter using addRemoteTextTrack()
This PR is to make sure that duplicate chapters do not get added to that list.

Specific Changes proposed

Changes proposed within this PR are as follows:

  1. We always keep our chapters item list clean and fresh each time a chapter is added, by always creating a new chapters list every single time
    This approach makes it easy to avoid duplicate chapters and only provide a new chapter item list whenever the user tries to create one.

Requirements Checklist

  • Feature implemented / Bug fixed
  • If necessary, more likely in a feature request than a bug fix
  • Reviewed by Two Core Contributors

let track = tracks[i];

// We will always choose the last track as our chaptersTrack
let track = tracks[length - 1];
Copy link
Member

Choose a reason for hiding this comment

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

wouldn't this always choose the last track? Don't we want the last chapters track?

Copy link
Member

Choose a reason for hiding this comment

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

Also, the track chosen here and in createItems is now different.

Copy link
Member

Choose a reason for hiding this comment

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

Actually, does this even need createItems since it's all happening in there? We should move the item creation login from this method into createItems.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think for the last chapters track, due to the break statement....it does not always choose the last track.
Let's say we have multiple chapters list and if one the in-between chapters kind matches ; it will choose a track from in-between of the list and break out from the loop.
I wanted to always make sure that we are taking the last track no matter how big the list is.

Also track chosen in createItems would be different, but we are popping out the items in createMenu while always maintaining a chapters list, so that would not be an issue I think.

Well we actually do not need createItems if we decide to take this approach.

Copy link
Member

Choose a reason for hiding this comment

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

but length never changes, so, it'll always choose track[track.length - 1]

Copy link
Member

Choose a reason for hiding this comment

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

I think moving things there is good because it'll be consistent with the other menu buttons.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, will try to see if I can move things around. :)

Regarding choosing the last track, earlier it was like this

for loop {
let track = tracks[i] 
(if track matches kind as chapters)  {
  chaptersTrack = track;
  break;
 }
}

Now let's say i = 1 and kind matches with chapters, 
but we want the 2nd track( i = 2) to be the correct and most recent 
chapters Track that has to be added to chapters list

This will cause the chaptersTrack to always take value of the first track, and break out from the loop.
If this happens, the last most recent track added never gets added to the list as chaptersTrack will always take value of the first previous track. Would this be not the case ?

@@ -97,6 +99,16 @@ class ChaptersButton extends TextTrackButton {
});
menu.children_.unshift(title);
Dom.insertElFirst(title, menu.contentEl());
this.addChild(menu);
}
else {
Copy link
Member

Choose a reason for hiding this comment

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

I think this should be on the previous line (i.e. } else {).

@@ -105,8 +105,6 @@ class Component {
*/
dispose() {
this.trigger({ type: 'dispose', bubbles: false });

// Dispose all children.
Copy link
Member

Choose a reason for hiding this comment

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

why remove this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added the comment back

Copy link
Member

Choose a reason for hiding this comment

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

This shouldn't be showing up as changed in the diff.

elData[id] = {};
}

let id = el[elIdAttr];
Copy link
Member

Choose a reason for hiding this comment

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

The indent is off. It shouldn't be showing up as changed in the diff.

@@ -105,7 +105,7 @@ class Component {
*/
dispose() {
this.trigger({ type: 'dispose', bubbles: false });

Copy link
Member

Choose a reason for hiding this comment

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

whitespace

@gkatsev gkatsev added patch This PR can be added to a patch release. needs: LGTM Needs one or more additional approvals labels Jun 9, 2016
@gkatsev
Copy link
Member

gkatsev commented Jun 9, 2016

LGTM

1 similar comment
@misteroneill
Copy link
Member

LGTM

@misteroneill misteroneill removed the needs: LGTM Needs one or more additional approvals label Jun 9, 2016
@gkatsev gkatsev closed this in 2a76453 Jun 28, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
confirmed patch This PR can be added to a patch release.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants