nbianca
(Bianca)
29 Abril, 2021 12:33
16
I submitted a fix for the bug in the first post:
master ← fix_uncategorized
merged 03:05AM - 04 May 21 UTC
Uncategorized was sometimes visible even if allow_uncategorized_topics
was fals… e. This was especially happening on mobile, if at least one
topic was uncategorized.
I went with the first solution because that is the one that deletes some code from Discourse. The other one in fact added code to determine if there is at least one topic in uncategorized category.
I also reviewed all uses of category.uncategorized? and I found a few places that might not be necessary if we made Uncategorized less of a unicorn and more of a category:
def name
object.uncategorized? ? I18n.t('uncategorized_category_name', locale: SiteSetting.default_locale) : object.name
end
def description_text
object.uncategorized? ? I18n.t('category.uncategorized_description', locale: SiteSetting.default_locale) : object.description_text
end
def description
object.uncategorized? ? I18n.t('category.uncategorized_description', locale: SiteSetting.default_locale) : object.description
end
def description_excerpt
object.uncategorized? ? I18n.t('category.uncategorized_description', locale: SiteSetting.default_locale) : object.description_excerpt
end
SELECT c2.id FROM categories c2
LEFT JOIN topics t ON t.id = c2.topic_id AND t.deleted_at IS NULL
WHERE t.id IS NULL AND c2.topic_id IS NOT NULL
)
SQL
DB.exec(sql)
Category
.joins('LEFT JOIN topics ON categories.topic_id = topics.id AND topics.deleted_at IS NULL')
.where('categories.id <> ?', SiteSetting.uncategorized_category_id)
.where(topics: { id: nil })
.find_each do |category|
category.create_category_definition
end
end
def slug_path
if self.parent_category_id.present?
slug_path = self.parent_category.slug_path
slug_path.push(self.slug_for_url)
These are some parts that do not interfere with other features, which makes the changes less risky, but still not easy.
6 Me gusta