From 98237207e67697abffc6b141f2388e3d8c925260 Mon Sep 17 00:00:00 2001 From: Claire Date: Thu, 22 Aug 2024 15:42:04 +0200 Subject: [PATCH] =?UTF-8?q?Fix=20unnecessary=20=E2=80=9Cnext=E2=80=9D=20li?= =?UTF-8?q?nk=20when=20API=20returns=20fewer=20notification=20requests=20t?= =?UTF-8?q?han=20requested=20(#31541)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/api/v1/notifications/requests_controller.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/controllers/api/v1/notifications/requests_controller.rb b/app/controllers/api/v1/notifications/requests_controller.rb index b820a2ed2e..36ee073b9c 100644 --- a/app/controllers/api/v1/notifications/requests_controller.rb +++ b/app/controllers/api/v1/notifications/requests_controller.rb @@ -75,13 +75,17 @@ class Api::V1::Notifications::RequestsController < Api::BaseController 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