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

Remove Multiple Downloads #1428

Merged
merged 14 commits into from
Jan 15, 2020
Merged

Remove Multiple Downloads #1428

merged 14 commits into from
Jan 15, 2020

Conversation

ataata107
Copy link

@ataata107 ataata107 commented Jan 6, 2020

Fixes #1419

Make sure these boxes are checked before your pull request (PR) is ready to be reviewed and merged. Thanks!

  • tests pass -- look for a green checkbox ✔️ a few minutes after opening your PR -- or run tests locally with npm test
  • code is in uniquely-named feature branch and has no merge conflicts
  • PR is descriptively titled
  • ask @publiclab/is-reviewers for help, in a comment below
  • Insert-step functionality is working correct as expected.

We're happy to help you get this ready -- don't be afraid to ask for help, and don't be discouraged if your tests fail at first!

ezgif com-video-to-gif

If tests do fail, click on the red X to learn why by reading the logs.

Please be sure you've reviewed our contribution guidelines at https://publiclab.org/contributing-to-public-lab-software
Please make sure to get at least two reviews before asking for merging the PR as that would make the PR more reliable on our part
Thanks!

@ataata107
Copy link
Author

@publiclab/is-reviewers

@codecov
Copy link

codecov bot commented Jan 6, 2020

Codecov Report

Merging #1428 into main will not change coverage.
The diff coverage is 0%.

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #1428   +/-   ##
=======================================
  Coverage   64.85%   64.85%           
=======================================
  Files         127      127           
  Lines        2598     2598           
  Branches      418      418           
=======================================
  Hits         1685     1685           
  Misses        913      913
Impacted Files Coverage Δ
examples/lib/defaultHtmlStepUi.js 11.23% <0%> (ø) ⬆️

@ataata107
Copy link
Author

@harshkhandeparkar added unbind method and removed the previous method. As the event listener gets triggered each time onComplete is called we need to unbind it from all the previous values.
Hope this method is much better than the previous one.

@@ -308,7 +308,7 @@ function DefaultHtmlStepUi(_sequencer, options) {
return output.split('/')[1].split(';')[0];
}

$stepAll('.download-btn').on('click', () => {
$stepAll('.download-btn').unbind().on('click', () => {
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 it be better to use .off('click') instead of unbind? unbind will remove all the event handlers but we only want the click event handler to be removed.

Copy link
Member

Choose a reason for hiding this comment

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

Also, did you find out why $stepAll is used here? This is a bit confusing. Does it work with just $step? If yes, then it would be better to use $step instead of $stepAll.

Wait, the error could be caused because of $stepAll. We want to add a download listener to the current step but $stepAll will add a listener to every step each time a new step is added. So every time a step is added, an extra listener will be added to the older steps. If I am not wrong then changing $stepAll to $step without unbind or off should fix everything.

Copy link
Author

Choose a reason for hiding this comment

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

Changing it to $step didn't work.
Isn't $stepAll derived from scopeSelectorAll which should basically mean to select all the instances of the element present inside the scope (i.e in the current step). By that shouldn't $stepAll refers to the all the elements in the current step.

Copy link
Member

Choose a reason for hiding this comment

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

Oh yeah! I guess I forgot myself. Lol. I was the one who added scopeQuery 😅.
Okay then your code should work fine. Will review again in a min.

Copy link
Author

Choose a reason for hiding this comment

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

Should I revert back to off(‘click) in this one?

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, I think you should. Sorry for the late response.

Copy link
Author

Choose a reason for hiding this comment

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

Done

Copy link
Member

@harshkhandeparkar harshkhandeparkar left a comment

Choose a reason for hiding this comment

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

👍

@jywarren
Copy link
Member

Great, thank you!!!

@jywarren jywarren merged commit 423422a into publiclab:main Jan 15, 2020
@jywarren
Copy link
Member

This is super work. We'd love a UI test for this if you're interested, to protect this functionality in the future? #1369

@ataata107
Copy link
Author

@jywarren thanks. Would love to do that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Clicking download btn downloads multiple Files
3 participants