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:
parent
2129e9e37a
commit
a6e06915c4
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue