1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 04:07:25 +08:00

Apply suggested changes

This commit is contained in:
Andrei Zavatski 2019-10-17 16:28:32 +03:00
parent a858e713f8
commit 9ee63a8c1a
2 changed files with 5 additions and 9 deletions

View File

@ -47,15 +47,11 @@ namespace osu.Game.Online.API.Requests.Responses
[JsonProperty(@"included_comments")]
public List<Comment> IncludedComments { get; set; }
private List<long> userVotes;
[JsonProperty(@"user_votes")]
public List<long> UserVotes
private List<long> userVotes
{
get => userVotes;
set
{
userVotes = value;
value.ForEach(v =>
{
Comments.ForEach(c =>

View File

@ -40,11 +40,11 @@ namespace osu.Game.Overlays.Comments
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 @@ namespace osu.Game.Overlays.Comments
{
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 @@ namespace osu.Game.Overlays.Comments
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 @@ namespace osu.Game.Overlays.Comments
}
}
private void setCount(int count) => votesCounter.Text = $"+{count}";
protected override void Dispose(bool isDisposing)
{
base.Dispose(isDisposing);