Merge pull request #7592 from EVAST9919/comments-counter-integration

Add TotalCommentsCounter to CommentsContainer
This commit is contained in:
Dean Herbert 2020-01-24 11:43:28 +09:00 committed by GitHub
commit 4bab8bcdcc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -38,6 +38,7 @@ namespace osu.Game.Overlays.Comments
private readonly FillFlowContainer content; private readonly FillFlowContainer content;
private readonly DeletedChildrenPlaceholder deletedChildrenPlaceholder; private readonly DeletedChildrenPlaceholder deletedChildrenPlaceholder;
private readonly CommentsShowMoreButton moreButton; private readonly CommentsShowMoreButton moreButton;
private readonly TotalCommentsCounter commentCounter;
public CommentsContainer() public CommentsContainer()
{ {
@ -56,6 +57,7 @@ namespace osu.Game.Overlays.Comments
Direction = FillDirection.Vertical, Direction = FillDirection.Vertical,
Children = new Drawable[] Children = new Drawable[]
{ {
commentCounter = new TotalCommentsCounter(),
new CommentsHeader new CommentsHeader
{ {
Sort = { BindTarget = Sort }, Sort = { BindTarget = Sort },
@ -133,6 +135,9 @@ namespace osu.Game.Overlays.Comments
if (!IsLoaded) if (!IsLoaded)
return; return;
// only reset when changing ID/type. other refetch ops are generally just changing sort order.
commentCounter.Current.Value = 0;
refetchComments(); refetchComments();
} }
@ -199,6 +204,8 @@ namespace osu.Game.Overlays.Comments
moreButton.IsLoading = false; moreButton.IsLoading = false;
} }
commentCounter.Current.Value = response.Total;
moreButton.FadeTo(response.HasMore ? 1 : 0); moreButton.FadeTo(response.HasMore ? 1 : 0);
}, loadCancellation.Token); }, loadCancellation.Token);
} }