ColinEberhardt / applause-button

A zero-configuration medium-style button for adding applause / claps / kudos to web pages and blog posts
http://applause-button.com/
MIT License
427 stars 41 forks source link

Clap count in UI is increment while the update is rejected by server #57

Open prabhu43 opened 4 years ago

prabhu43 commented 4 years ago

Once a user clap for second time after page refresh, It increments the count in UI. But the update api call does not increase the count as the clap limit exceeded for the user from that IP, it returns the same old value for clap count.

Expected:

If the clap limit exceeded for the user(source ip), disable the button on initialisation(page refresh)

Solutions:

  1. Update the count in UI after getting response from updateClaps api call
  2. Disable applause button by adding "clap-limit-exceeded" class on initialisation(page refresh)
prabhu43 commented 4 years ago

@ColinEberhardt Let me know which solution is preferable. I can fix this issue.

android10 commented 3 years ago

Any update on this one?

I opened another issue probably related to this one due to the introduction of clap-limit-exceeded

Here is the link: https://github.com/ColinEberhardt/applause-button/issues/69

Thanks for such a great job @ColinEberhardt ❤️

ColinEberhardt commented 3 years ago

Thanks for the suggestions - this is a tricky issue, and one that always has an element of compromise. I've made a recent update that works as follows:

  1. I've added some styling for the clap-count-exceeded state so that it is visible to the user https://github.com/ColinEberhardt/applause-button/commit/7d346ef4aecbc41db91ace1b923b6cfaad0b97d9
  2. When the clap increment is sent to the server, the code now checks the returned value to see if an increment has actually taken place. If not, the clap-count-exceeded style is applied, and the clap count reset to the server-side value https://github.com/ColinEberhardt/applause-button/commit/eed48b80cd97bf36a9e5f9450757e6540881bbef

This does result in some behaviour that users might find unexpected:

  1. If they have reached their (IP specific) clap limit, refresh the page, then click the button, the UI will register the update - but 2 seconds later, the button will gray-out and reset the counter value. People might find this confusing.
  2. In multi-clap mode, the user can only send one 'multi clap burst' of claps. If they, for example, clap 3 times in quick succession, pause, then clap another 3 times, only the first 3 will register.
android10 commented 3 years ago

@ColinEberhardt thanks for taking care of this! Amazing job! ❤️