forked from treehouse/mastodon
Support min_id-based pagination for bookmarks (#12381)
* Support min_id-based pagination for bookmarks * Fix specsignup-info-prompt
parent
df15a2cd37
commit
5a2c0707f1
|
@ -26,10 +26,9 @@ class Api::V1::BookmarksController < Api::BaseController
|
||||||
end
|
end
|
||||||
|
|
||||||
def results
|
def results
|
||||||
@_results ||= account_bookmarks.paginate_by_max_id(
|
@_results ||= account_bookmarks.paginate_by_id(
|
||||||
limit_param(DEFAULT_STATUSES_LIMIT),
|
limit_param(DEFAULT_STATUSES_LIMIT),
|
||||||
params[:max_id],
|
params_slice(:max_id, :since_id, :min_id)
|
||||||
params[:since_id]
|
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -46,7 +45,7 @@ class Api::V1::BookmarksController < Api::BaseController
|
||||||
end
|
end
|
||||||
|
|
||||||
def prev_path
|
def prev_path
|
||||||
api_v1_bookmarks_url pagination_params(since_id: pagination_since_id) unless results.empty?
|
api_v1_bookmarks_url pagination_params(min_id: pagination_since_id) unless results.empty?
|
||||||
end
|
end
|
||||||
|
|
||||||
def pagination_max_id
|
def pagination_max_id
|
||||||
|
|
|
@ -64,7 +64,7 @@ RSpec.describe Api::V1::BookmarksController, type: :controller do
|
||||||
get :index, params: { limit: 1 }
|
get :index, params: { limit: 1 }
|
||||||
|
|
||||||
expect(response.headers['Link'].find_link(['rel', 'next']).href).to eq "http://test.host/api/v1/bookmarks?limit=1&max_id=#{bookmark.id}"
|
expect(response.headers['Link'].find_link(['rel', 'next']).href).to eq "http://test.host/api/v1/bookmarks?limit=1&max_id=#{bookmark.id}"
|
||||||
expect(response.headers['Link'].find_link(['rel', 'prev']).href).to eq "http://test.host/api/v1/bookmarks?limit=1&since_id=#{bookmark.id}"
|
expect(response.headers['Link'].find_link(['rel', 'prev']).href).to eq "http://test.host/api/v1/bookmarks?limit=1&min_id=#{bookmark.id}"
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does not add pagination headers if not necessary' do
|
it 'does not add pagination headers if not necessary' do
|
||||||
|
|
Loading…
Reference in New Issue