-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Likes Fix (button mashing and initial negative likes) #4852
Conversation
Generated by 🚫 Danger |
@jywarren From working with this code I have felt like the notification popups UI isn't compatible with the 'like' and 'unlike' functionalities. I was thinking maybe to just remove them all together as they might be replaced when a notifications API is fully integrated with the site. Please see my comments and GIFs in the link in my PR description and let me know your thoughts! Thank you |
@sashadev-sky can you please add Gif |
@avsingh999 the Gif is linked in the PR request description. It wouldn't let me drag it here because the file was too large |
Sorry I didn't see 😄 |
Hi @sashadev-sky, the right approach for doing this according to me is update the likes when we get the response with the number of likes. And disable the button when the request is taking place of the previous like. What do you think? |
@namangupta01 I think disabling a button does not prevent event listeners from firing. So that is why I had to make sure to turn them off in between promises |
By disabling the button, I mean to stop progressing the event when request is going on using |
} | ||
|
||
// note useful for comments on notes but maybe useful for something else. | ||
// if(window.location.href.includes("#like")) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be better to remove unused code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don’t think code should be deleted before you know the reason it was put there in the first place. As noted in its comment I am still investigating that and this PR is not labeled for review. If you have input on the function of it that would be useful. Thank you
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could look through the blame view for this file to see when it was added and when removed, and see if you can track it that way!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It actually doesn't do anything helpful I looked into it. But instead of removing it I will comment it out. I think I will open a new issue after this for implementing likes on comments (currently not working) and fix it up there. Is that okay with everyone? So the uncommented code will just be there for a bit.
@namangupta01 this pull request is marked as “in progress” I will make the gem updates when I’m ready for merge review 👍🏻 |
No problem, let me know if you need some help! 👍 |
@namangupta01 I don't quite understand the change you are suggesting. I don't think preventdefault should have any effect on the button in this scenario as it is not a form submission also if you could help me write front end tests that would be great!! It's my first time writing them I could use some help |
Hi @sashadev-sky - by https://github.com/publiclab/plots2/blob/master/doc/TESTING.md#client-side-tests I'm also interested in exploring system tests, in #3683, and i just opened a PR here: #4888 (though not sure if it will run). That will actually run a full-stack version of the site in Chrome, and allows click interactions, so it really tests the whole system. I think this could be a good way forward for testing likes and we may want to move away from the teaspoon/mocha tests since they can't test on dynamic data, and require the static fixtures to be maintained. What do you think? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small changes - likers.count - but all good otherwise! Good work here! This has long been a bit of an untidy part of our JS code. Thanks!
f7b12d6
to
c672c96
Compare
Spinner idea: you could also add |
Folks have asked about what debounce means and how this strategy works. @sashadev-sky here's a link to a great explanation: https://css-tricks.com/debouncing-throttling-explained-examples/ -- it can really help throttle client/server interactions and make things smoother. I recently implemented it in this PR with @aashna27 's help: #4904 Example of debounce: https://github.com/publiclab/plots2/pull/4904/files#diff-128f89a0762ba84f1ad9619753645287R15 |
$('.myButton').click(debounce(function onClick(){
// ... do things
}, 350); 350 is the # of milliseconds. Play around with 100-350 range |
@jywarren likes are debounced! Please review. Not much update to show in terms of UI so the gif in the description is basically the same still as what I saw when running it on the unstable branch. I also saw from the waterfall in Chrome dev tools that the debounce is taking pauses for the requests and not every click will lead to a request when mashing the button. |
Awesome and well done here!!! |
* version updates * squash commits * leave note for bridge into next likes functionaliy fix * squash commits * leave note for bridge into next likes functionaliy fix * disable noty notification for likes and comment likes * fix comment template if statement * updates * check no debounce * debounce likes * debounce
* version updates * squash commits * leave note for bridge into next likes functionaliy fix * squash commits * leave note for bridge into next likes functionaliy fix * disable noty notification for likes and comment likes * fix comment template if statement * updates * check no debounce * debounce likes * debounce
Fixes #3524, #4589
Make sure these boxes are checked before your pull request (PR) is ready to be reviewed and merged. Thanks!
rake test
@publiclab/reviewers
for help, in a comment below================
Please find notes and GIFs here:
https://github.com/sashadev-sky/PL-notes/blob/master/likes.md
===============