mirror of
https://github.com/discourse/discourse.git
synced 2024-12-11 17:05:47 +08:00
e3977f84a3
What is the problem? We have a hidden site setting `show_category_definitions_in_topic_lists` which is set to false by default. What this means is that category definition topics are not shown in the topic list by default. Only the category definition topic for the category being viewed will be shown. However, we have a bug where we would show that a category has new topics when a new child category along with its category definition topic is created even though the topic list does not list the child category's category definition topic. What is the fix here? This commit fixes the problem by shipping down an additional `is_category_topic` attribute in `TopicTrackingStateItemSerializer` when the `show_category_definitions_in_topic_lists` site setting has been set to false. With the new attribute, we can then exclude counting child categories' category definition topics when counting new and unread counts for a category.
32 lines
750 B
Ruby
32 lines
750 B
Ruby
# frozen_string_literal: true
|
|
|
|
class TopicTrackingStateItemSerializer < ApplicationSerializer
|
|
attributes :topic_id,
|
|
:highest_post_number,
|
|
:last_read_post_number,
|
|
:created_at,
|
|
:category_id,
|
|
:is_category_topic,
|
|
:notification_level,
|
|
:created_in_new_period,
|
|
:treat_as_new_topic_start_date,
|
|
:tags
|
|
|
|
def created_in_new_period
|
|
return true if !scope
|
|
object.created_at >= treat_as_new_topic_start_date
|
|
end
|
|
|
|
def include_tags?
|
|
object.respond_to?(:tags)
|
|
end
|
|
|
|
def is_category_topic
|
|
object.topic_id == object.category_topic_id
|
|
end
|
|
|
|
def include_is_category_topic?
|
|
object.respond_to?(:category_topic_id)
|
|
end
|
|
end
|