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:
Bianca Nenciu
2024-04-17 17:23:47 +03:00
committed by GitHub
parent c9a46cfdda
commit 9638ce17fa
6 changed files with 36 additions and 2 deletions

View File

@@ -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