Skip to content

Commit

Permalink
Fix votes remaining lag.
Browse files Browse the repository at this point in the history
  • Loading branch information
bilus committed Sep 15, 2020
1 parent 930e05a commit 5bea62a
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions actions/votes.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ func (c PostsController) VotesCreate() error {
return c.Render(http.StatusUnprocessableEntity, r.JavaScript("error.js"))
}

votesRemaining, err := c.VotingService.VotesRemaining(&c.CurrentUser, c.Board)
if err == nil {
c.Set("votesRemaining", votesRemaining)
}

c.Set("post", c.Post)
c.Set("board", &c.Post.Board)
return c.Render(http.StatusOK, r.JavaScript("votes/create.js"))
Expand All @@ -56,6 +61,12 @@ func (c PostsController) VotesDestroy() error {
} else {
return c.Render(http.StatusUnprocessableEntity, r.JavaScript("votes/fail.js"))
}

votesRemaining, err := c.VotingService.VotesRemaining(&c.CurrentUser, c.Board)
if err == nil {
c.Set("votesRemaining", votesRemaining)
}

c.Set("post", c.Post)
c.Set("board", &c.Post.Board)
return c.Render(http.StatusOK, r.JavaScript("votes/destroy.js"))
Expand Down

0 comments on commit 5bea62a

Please sign in to comment.