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
|
def categories
|
||||||
@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
|
end
|
||||||
|
|
||||||
def load_topics
|
def load_topics
|
||||||
|
|
|
@ -727,9 +727,9 @@ class TopicView
|
||||||
end
|
end
|
||||||
|
|
||||||
def categories
|
def categories
|
||||||
categories = [category, category&.parent_category]
|
@categories ||= [category&.parent_category, category, suggested_topics&.categories].flatten
|
||||||
categories += suggested_topics.categories if suggested_topics
|
.uniq
|
||||||
categories.compact.uniq
|
.compact
|
||||||
end
|
end
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
Loading…
Reference in New Issue