mirror of
https://github.com/ppy/osu.git
synced 2025-01-13 16:32:54 +08:00
Apply suggested changes
This commit is contained in:
parent
a858e713f8
commit
9ee63a8c1a
@ -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 =>
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user