Skip to content

Commit

Permalink
Call it after instead to match existing parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
nanaya committed Jul 11, 2023
1 parent 3cfb42a commit 7d9bd08
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 11 deletions.
2 changes: 1 addition & 1 deletion app/Http/Controllers/CommentsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public function destroy($id)
*
* `pinned_comments` is only included when `commentable_type` and `commentable_id` are specified.
*
* @queryParam after_id Return comments which come after the specified comment id as per sort option. No-example
* @queryParam after Return comments which come after the specified comment id as per sort option. No-example
* @queryParam commentable_type The type of resource to get comments for. Example: beatmapset
* @queryParam commentable_id The id of the resource to get comments for. Example: 1
* @queryParam cursor Pagination option. See [CommentSort](#commentsort) for detail. The format follows [Cursor](#cursor) except it's not currently included in the response. No-example
Expand Down
4 changes: 2 additions & 2 deletions app/Libraries/CommentBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,10 +183,10 @@ private function getComments($query, $isChildren = true, $pinnedOnly = false)

$queryLimit++;

if ($this->params->afterId === null) {
if ($this->params->after === null) {
$cursor = $this->params->cursor;
} else {
$lastComment = Comment::findOrFail($this->params->afterId);
$lastComment = Comment::findOrFail($this->params->after);
$cursor = $cursorHelper->next([$lastComment]);
}

Expand Down
4 changes: 2 additions & 2 deletions app/Libraries/CommentBundleParams.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class CommentBundleParams
const DEFAULT_PAGE = 1;
const DEFAULT_LIMIT = 50;

public ?int $afterId = null;
public ?int $after = null;
public $userId;
public $commentableId;
public $commentableType;
Expand Down Expand Up @@ -65,7 +65,7 @@ public function setAll($params)
$this->cursorHelper = Comment::makeDbCursorHelper($params['sort'] ?? $this->sort);
$this->cursor = get_arr($params['cursor'] ?? null);
$this->sort = $this->cursorHelper->getSortName();
$this->afterId = get_int($params['after_id'] ?? null);
$this->after = get_int($params['after'] ?? null);
}

public function filterByParentId()
Expand Down
7 changes: 1 addition & 6 deletions resources/js/components/comment-show-more.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,7 @@ export default class CommentShowMore extends React.Component<Props> {

const lastComment = last(this.props.comments);
if (lastComment != null) {
// TODO: convert to plain after_id params of some sort instead of cursor
params.cursor = {
created_at: lastComment.createdAt,
id: lastComment.id,
votes_count: lastComment.votesCount,
};
params.after = lastComment.id;
}

this.xhr = $.ajax(route('comments.index'), { data: params, dataType: 'json' });
Expand Down

0 comments on commit 7d9bd08

Please sign in to comment.