discourse/app/serializers/user_bookmark_list_serializer.rb
Bianca Nenciu 9638ce17fa
FIX: Serialize categories for bookmarks (#26606)
This is necessary when "lazy load categories" feature is enabled to make
sure the categories are rendered for topics and posts.
2024-04-17 17:23:47 +03:00

27 lines
596 B
Ruby

# frozen_string_literal: true
class UserBookmarkListSerializer < ApplicationSerializer
attributes :more_bookmarks_url, :bookmarks
has_many :categories, serializer: CategoryBadgeSerializer, embed: :objects
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
def include_categories?
scope.can_lazy_load_categories?
end
end