diff --git a/osu.Game/Online/API/Requests/Responses/CommentBundle.cs b/osu.Game/Online/API/Requests/Responses/CommentBundle.cs index f910c738ac..7db3126ade 100644 --- a/osu.Game/Online/API/Requests/Responses/CommentBundle.cs +++ b/osu.Game/Online/API/Requests/Responses/CommentBundle.cs @@ -47,15 +47,11 @@ public List Comments [JsonProperty(@"included_comments")] public List IncludedComments { get; set; } - private List userVotes; - [JsonProperty(@"user_votes")] - public List UserVotes + private List userVotes { - get => userVotes; set { - userVotes = value; value.ForEach(v => { Comments.ForEach(c => diff --git a/osu.Game/Overlays/Comments/VotePill.cs b/osu.Game/Overlays/Comments/VotePill.cs index cd50546b45..d8288c8ec4 100644 --- a/osu.Game/Overlays/Comments/VotePill.cs +++ b/osu.Game/Overlays/Comments/VotePill.cs @@ -40,11 +40,11 @@ public class VotePill : LoadingButton, IHasAccentColour private CommentVoteRequest request; private readonly BindableBool isVoted = new BindableBool(); + private readonly BindableInt votesCount = new BindableInt(); public VotePill(Comment comment) { this.comment = comment; - setCount(comment.VotesCount); Action = onAction; @@ -64,7 +64,9 @@ protected override void LoadComplete() { base.LoadComplete(); isVoted.Value = comment.IsVoted; + votesCount.Value = comment.VotesCount; isVoted.BindValueChanged(voted => background.Colour = voted.NewValue ? AccentColour : OsuColour.Gray(0.05f), true); + votesCount.BindValueChanged(count => votesCounter.Text = $"+{count.NewValue}", true); } private void onAction() @@ -77,7 +79,7 @@ private void onAction() private void onSuccess(CommentBundle response) { isVoted.Value = !isVoted.Value; - setCount(response.Comments.First().VotesCount); + votesCount.Value = response.Comments.Single().VotesCount; IsLoading = false; } @@ -168,8 +170,6 @@ private void onHoverAction() } } - private void setCount(int count) => votesCounter.Text = $"+{count}"; - protected override void Dispose(bool isDisposing) { base.Dispose(isDisposing);