diff --git a/osu.Game/Online/API/Requests/GetCommentRepliesRequest.cs b/osu.Game/Online/API/Requests/GetCommentRepliesRequest.cs deleted file mode 100644 index 203f5d5635..0000000000 --- a/osu.Game/Online/API/Requests/GetCommentRepliesRequest.cs +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. -// See the LICENCE file in the repository root for full licence text. - -using Humanizer; -using osu.Framework.IO.Network; -using osu.Game.Online.API.Requests.Responses; -using osu.Game.Overlays.Comments; - -namespace osu.Game.Online.API.Requests -{ - public class GetCommentRepliesRequest : APIRequest - { - private readonly long commentId; - private readonly CommentableType commentableType; - private readonly long commentableId; - private readonly int page; - private readonly CommentsSortCriteria sort; - - public GetCommentRepliesRequest(long commentId, CommentableType commentableType, long commentableId, CommentsSortCriteria sort, int page) - { - this.commentId = commentId; - this.page = page; - this.sort = sort; - - // These parameters are necessary to get deleted comments - this.commentableType = commentableType; - this.commentableId = commentableId; - } - - protected override WebRequest CreateWebRequest() - { - var req = base.CreateWebRequest(); - - req.AddParameter("parent_id", commentId.ToString()); - req.AddParameter("sort", sort.ToString().ToLowerInvariant()); - req.AddParameter("commentable_type", commentableType.ToString().Underscore().ToLowerInvariant()); - req.AddParameter("commentable_id", commentableId.ToString()); - req.AddParameter("page", page.ToString()); - - return req; - } - - protected override string Target => "comments"; - } -} diff --git a/osu.Game/Online/API/Requests/GetCommentsRequest.cs b/osu.Game/Online/API/Requests/GetCommentsRequest.cs index 7763501860..24dae4adf1 100644 --- a/osu.Game/Online/API/Requests/GetCommentsRequest.cs +++ b/osu.Game/Online/API/Requests/GetCommentsRequest.cs @@ -10,27 +10,32 @@ namespace osu.Game.Online.API.Requests { public class GetCommentsRequest : APIRequest { - private readonly long id; - private readonly int page; + private readonly long commentableId; private readonly CommentableType type; private readonly CommentsSortCriteria sort; + private readonly int page; + private readonly long? parentId; - public GetCommentsRequest(CommentableType type, long id, CommentsSortCriteria sort = CommentsSortCriteria.New, int page = 1) + public GetCommentsRequest(long commentableId, CommentableType type, CommentsSortCriteria sort = CommentsSortCriteria.New, int page = 1, long? parentId = null) { + this.commentableId = commentableId; this.type = type; this.sort = sort; - this.id = id; this.page = page; + this.parentId = parentId; } protected override WebRequest CreateWebRequest() { var req = base.CreateWebRequest(); + req.AddParameter("commentable_id", commentableId.ToString()); req.AddParameter("commentable_type", type.ToString().Underscore().ToLowerInvariant()); - req.AddParameter("commentable_id", id.ToString()); - req.AddParameter("sort", sort.ToString().ToLowerInvariant()); req.AddParameter("page", page.ToString()); + req.AddParameter("sort", sort.ToString().ToLowerInvariant()); + + if (parentId != null) + req.AddParameter("parent_id", parentId.ToString()); return req; } diff --git a/osu.Game/Overlays/Comments/CommentsContainer.cs b/osu.Game/Overlays/Comments/CommentsContainer.cs index 751fd8a353..5a04f6b4c4 100644 --- a/osu.Game/Overlays/Comments/CommentsContainer.cs +++ b/osu.Game/Overlays/Comments/CommentsContainer.cs @@ -152,7 +152,7 @@ namespace osu.Game.Overlays.Comments request?.Cancel(); loadCancellation?.Cancel(); - request = new GetCommentsRequest(type.Value, id.Value, Sort.Value, currentPage++); + request = new GetCommentsRequest(id.Value, type.Value, Sort.Value, currentPage++, 0); request.Success += onSuccess; api.PerformAsync(request); } diff --git a/osu.Game/Overlays/Comments/CommentsPage.cs b/osu.Game/Overlays/Comments/CommentsPage.cs index 9255a39c22..2715ea791b 100644 --- a/osu.Game/Overlays/Comments/CommentsPage.cs +++ b/osu.Game/Overlays/Comments/CommentsPage.cs @@ -123,7 +123,7 @@ namespace osu.Game.Overlays.Comments private void onCommentRepliesRequested(DrawableComment drawableComment, int page) { - var request = new GetCommentRepliesRequest(drawableComment.Comment.Id, Type.Value, CommentableId.Value, Sort.Value, page); + var request = new GetCommentsRequest(CommentableId.Value, Type.Value, Sort.Value, page, drawableComment.Comment.Id); request.Success += response => Schedule(() => appendComments(drawableComment, response));