Clap count in UI is increment while the update is rejected by server
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:
- Update the count in UI after getting response from updateClaps api call
- Disable applause button by adding "clap-limit-exceeded" class on initialisation(page refresh)
@ColinEberhardt Let me know which solution is preferable. I can fix this issue.
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 ❤️
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:
- I've added some styling for the
clap-count-exceededstate so that it is visible to the user https://github.com/ColinEberhardt/applause-button/commit/7d346ef4aecbc41db91ace1b923b6cfaad0b97d9 - 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-exceededstyle 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:
- 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.
- 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 thanks for taking care of this! Amazing job! ❤️