FIX: don't send xhr request when vote limit is reached (#57)

FIX: don’t send xhr request when vote limit is reached (#57)

When the user used all the votes we should not send a request to create a vote. We should only display information about votes.

The bug was mentioned on meta: https://meta.discourse.org/t/the-vote-button-should-be-disabled-when-the-limit-is-reached/68902

diff --git a/assets/javascripts/discourse/widgets/vote-button.js.es6 b/assets/javascripts/discourse/widgets/vote-button.js.es6
index 47100d7..26d2397 100644
--- a/assets/javascripts/discourse/widgets/vote-button.js.es6
+++ b/assets/javascripts/discourse/widgets/vote-button.js.es6
@@ -77,7 +77,8 @@ export default createWidget("vote-button", {
     if (
       !this.attrs.closed &&
       this.parentWidget.state.allowClick &&
-      !this.attrs.user_voted
+      !this.attrs.user_voted &&
+      !this.currentUser.votes_exceeded
     ) {
       this.parentWidget.state.allowClick = false;
       this.parentWidget.state.initialVote = true;

GitHub sha: 1d501226

1 Like

This commit appears in #57 which was approved by SamSaffron. It was merged by SamSaffron.