discourse/app/serializers/user_bookmark_list_serializer.rb
Bianca Nenciu 5092c9804c
FIX: Return next bookmarks page only if it exists (#18139)
It used to return the next URL anyway which lead to an additional
request. On the frontend, if the result set was empty, it kept retrying
until at least one result was returned. This bug is fixed in this commit
too.
2022-09-01 13:04:00 +03:00

21 lines
448 B
Ruby

# frozen_string_literal: true
class UserBookmarkListSerializer < ApplicationSerializer
attributes :more_bookmarks_url, :bookmarks
def bookmarks
object.bookmarks.map do |bm|
bm.registered_bookmarkable.serializer.new(
bm,
**object.bookmark_serializer_opts,
scope: scope,
root: false
)
end
end
def include_more_bookmarks_url?
@include_more_bookmarks_url ||= object.has_more
end
end