mirror of
https://github.com/discourse/discourse.git
synced 2024-12-24 17:26:09 +08:00
9638ce17fa
This is necessary when "lazy load categories" feature is enabled to make sure the categories are rendered for topics and posts.
27 lines
596 B
Ruby
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
|