Merge pull request #1204 from Retrospring/fix/exclude-pinned-answers-from-pagination

Exclude pinned answers from pagination queries
This commit is contained in:
Karina Kwiatek 2023-05-08 20:35:24 +02:00 committed by GitHub
commit 65d165aa26
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 1 deletions

View File

@ -4,8 +4,8 @@ module PaginatesAnswers
def paginate_answers
@answers = yield(last_id: params[:last_id])
answer_ids = @answers.map(&:id)
answer_ids += @pinned_answers.pluck(:id) if @pinned_answers.present?
@answers_last_id = answer_ids.min
answer_ids += @pinned_answers.pluck(:id) if @pinned_answers.present?
@more_data_available = !yield(last_id: @answers_last_id, size: 1).count.zero?
@subscribed_answer_ids = Subscription.where(user: current_user, answer_id: answer_ids).pluck(:answer_id) if user_signed_in?
end