mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 17:47:29 +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")]
|
[JsonProperty(@"included_comments")]
|
||||||
public List<Comment> IncludedComments { get; set; }
|
public List<Comment> IncludedComments { get; set; }
|
||||||
|
|
||||||
private List<long> userVotes;
|
|
||||||
|
|
||||||
[JsonProperty(@"user_votes")]
|
[JsonProperty(@"user_votes")]
|
||||||
public List<long> UserVotes
|
private List<long> userVotes
|
||||||
{
|
{
|
||||||
get => userVotes;
|
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
userVotes = value;
|
|
||||||
value.ForEach(v =>
|
value.ForEach(v =>
|
||||||
{
|
{
|
||||||
Comments.ForEach(c =>
|
Comments.ForEach(c =>
|
||||||
|
@ -40,11 +40,11 @@ namespace osu.Game.Overlays.Comments
|
|||||||
private CommentVoteRequest request;
|
private CommentVoteRequest request;
|
||||||
|
|
||||||
private readonly BindableBool isVoted = new BindableBool();
|
private readonly BindableBool isVoted = new BindableBool();
|
||||||
|
private readonly BindableInt votesCount = new BindableInt();
|
||||||
|
|
||||||
public VotePill(Comment comment)
|
public VotePill(Comment comment)
|
||||||
{
|
{
|
||||||
this.comment = comment;
|
this.comment = comment;
|
||||||
setCount(comment.VotesCount);
|
|
||||||
|
|
||||||
Action = onAction;
|
Action = onAction;
|
||||||
|
|
||||||
@ -64,7 +64,9 @@ namespace osu.Game.Overlays.Comments
|
|||||||
{
|
{
|
||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
isVoted.Value = comment.IsVoted;
|
isVoted.Value = comment.IsVoted;
|
||||||
|
votesCount.Value = comment.VotesCount;
|
||||||
isVoted.BindValueChanged(voted => background.Colour = voted.NewValue ? AccentColour : OsuColour.Gray(0.05f), true);
|
isVoted.BindValueChanged(voted => background.Colour = voted.NewValue ? AccentColour : OsuColour.Gray(0.05f), true);
|
||||||
|
votesCount.BindValueChanged(count => votesCounter.Text = $"+{count.NewValue}", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onAction()
|
private void onAction()
|
||||||
@ -77,7 +79,7 @@ namespace osu.Game.Overlays.Comments
|
|||||||
private void onSuccess(CommentBundle response)
|
private void onSuccess(CommentBundle response)
|
||||||
{
|
{
|
||||||
isVoted.Value = !isVoted.Value;
|
isVoted.Value = !isVoted.Value;
|
||||||
setCount(response.Comments.First().VotesCount);
|
votesCount.Value = response.Comments.Single().VotesCount;
|
||||||
IsLoading = false;
|
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)
|
protected override void Dispose(bool isDisposing)
|
||||||
{
|
{
|
||||||
base.Dispose(isDisposing);
|
base.Dispose(isDisposing);
|
||||||
|
Loading…
Reference in New Issue
Block a user