Skip to content

Commit

Permalink
Fix unnecessary “next” link when API returns fewer notification reque…
Browse files Browse the repository at this point in the history
…sts than requested (mastodon#31541)
  • Loading branch information
ClearlyClaire authored Aug 22, 2024
1 parent abe292b commit 9823720
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion app/controllers/api/v1/notifications/requests_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,17 @@ def set_requests
end

def next_path
api_v1_notifications_requests_url pagination_params(max_id: pagination_max_id) unless @requests.empty?
api_v1_notifications_requests_url pagination_params(max_id: pagination_max_id) if records_continue?
end

def prev_path
api_v1_notifications_requests_url pagination_params(min_id: pagination_since_id) unless @requests.empty?
end

def records_continue?
@requests.size == limit_param(DEFAULT_ACCOUNTS_LIMIT)
end

def pagination_max_id
@requests.last.id
end
Expand Down

0 comments on commit 9823720

Please sign in to comment.