FIX: Serialize parent categories first (#26294)

When categories are loaded by the frontend, the parent category is
looked up by ID and the `parentCategory` is set with the result. If the
categories returned are not in order, the parent category may miss.
This commit is contained in:
Bianca Nenciu 2024-03-21 19:51:41 +02:00 committed by GitHub
parent 2129e9e37a
commit a6e06915c4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 4 additions and 4 deletions

View File

@ -77,7 +77,7 @@ class TopicList
def categories
@categories ||=
topics.map { |t| [t.category&.parent_category, t.category] }.uniq.flatten.compact
topics.map { |t| [t.category&.parent_category, t.category] }.flatten.uniq.compact
end
def load_topics

View File

@ -727,9 +727,9 @@ class TopicView
end
def categories
categories = [category, category&.parent_category]
categories += suggested_topics.categories if suggested_topics
categories.compact.uniq
@categories ||= [category&.parent_category, category, suggested_topics&.categories].flatten
.uniq
.compact
end
protected