mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
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.
This commit is contained in:
@@ -36,4 +36,16 @@ class UserBookmarkList
|
||||
@has_more = (@page.to_i + 1) * @per_page < query.count
|
||||
@bookmarks
|
||||
end
|
||||
|
||||
def categories
|
||||
@categories ||=
|
||||
@bookmarks
|
||||
.map do |bm|
|
||||
category = bm.bookmarkable.try(:category) || bm.bookmarkable.try(:topic)&.category
|
||||
[category&.parent_category, category]
|
||||
end
|
||||
.flatten
|
||||
.compact
|
||||
.uniq
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user