applause-button icon indicating copy to clipboard operation
applause-button copied to clipboard

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

Open prabhu43 opened this issue 5 years ago • 4 comments

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 avatar Jul 07 '20 15:07 prabhu43

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

prabhu43 avatar Jul 07 '20 15:07 prabhu43

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 ❤️

android10 avatar Jan 08 '21 11:01 android10

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.

ColinEberhardt avatar Jan 11 '21 11:01 ColinEberhardt

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

android10 avatar Jan 12 '21 21:01 android10