1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-15 01:02:55 +08:00

Remove initial filed

This commit is contained in:
Andrei Zavatski 2019-10-15 11:25:58 +03:00
parent 3c714dc013
commit eb5dad08aa
3 changed files with 21 additions and 19 deletions

View File

@ -78,6 +78,6 @@ namespace osu.Game.Online.API.Requests.Responses
return WebUtility.HtmlDecode(Regex.Replace(MessageHtml, @"<(.|\n)*?>", string.Empty)); return WebUtility.HtmlDecode(Regex.Replace(MessageHtml, @"<(.|\n)*?>", string.Empty));
} }
public int GetDeletedChildrenCount => ChildComments.Select(c => c.IsDeleted).Count(c => c); public int DeletedChildrenCount => ChildComments.Count(c => c.IsDeleted);
} }
} }

View File

@ -101,7 +101,7 @@ namespace osu.Game.Overlays.Comments
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Origin = Anchor.Centre, Origin = Anchor.Centre,
Margin = new MarginPadding(5), Margin = new MarginPadding(5),
Action = () => getComments(false), Action = getComments
} }
} }
} }
@ -119,27 +119,31 @@ namespace osu.Game.Overlays.Comments
base.LoadComplete(); base.LoadComplete();
} }
private void onSortChanged(ValueChangedEvent<CommentsSortCriteria> sort) => getComments(); private void onSortChanged(ValueChangedEvent<CommentsSortCriteria> sort)
private void getComments(bool initial = true)
{ {
if (initial) clearComments();
{ getComments();
currentPage = 1; }
loadedTopLevelComments = 0;
deletedChildrenPlaceholder.DeletedCount.Value = 0;
moreButton.IsLoading = true;
content.Clear();
}
private void getComments()
{
request?.Cancel(); request?.Cancel();
loadCancellation?.Cancel(); loadCancellation?.Cancel();
request = new GetCommentsRequest(type, id, Sort.Value, currentPage++); request = new GetCommentsRequest(type, id, Sort.Value, currentPage++);
request.Success += response => onSuccess(response, initial); request.Success += response => onSuccess(response);
api.Queue(request); api.Queue(request);
} }
private void onSuccess(CommentBundle response, bool initial) private void clearComments()
{
currentPage = 1;
loadedTopLevelComments = 0;
deletedChildrenPlaceholder.DeletedCount.Value = 0;
moreButton.IsLoading = true;
content.Clear();
}
private void onSuccess(CommentBundle response)
{ {
loadCancellation = new CancellationTokenSource(); loadCancellation = new CancellationTokenSource();
@ -163,9 +167,7 @@ namespace osu.Game.Overlays.Comments
{ {
content.Add(loaded); content.Add(loaded);
int deletedComments = response.Comments.Select(c => c.IsDeleted && c.IsTopLevel).Count(c => c); deletedChildrenPlaceholder.DeletedCount.Value += response.Comments.Count(c => c.IsDeleted && c.IsTopLevel);
deletedChildrenPlaceholder.DeletedCount.Value = initial ? deletedComments : deletedChildrenPlaceholder.DeletedCount.Value + deletedComments;
if (response.HasMore) if (response.HasMore)
{ {

View File

@ -180,7 +180,7 @@ namespace osu.Game.Overlays.Comments
} }
}; };
deletedChildrenPlaceholder.DeletedCount.Value = comment.GetDeletedChildrenCount; deletedChildrenPlaceholder.DeletedCount.Value = comment.DeletedChildrenCount;
if (comment.UserId.HasValue) if (comment.UserId.HasValue)
username.AddUserLink(comment.User); username.AddUserLink(comment.User);