mirror of
https://github.com/discourse/discourse.git
synced 2024-11-29 04:03:57 -06:00
FIX: Pinned posts were not displaying at the top of categories.
This commit is contained in:
parent
965a0a91a2
commit
be5de4244c
@ -222,18 +222,7 @@ class TopicQuery
|
||||
result = result.joins("LEFT OUTER JOIN topic_users AS tu ON (topics.id = tu.topic_id AND tu.user_id = #{@user.id.to_i})")
|
||||
end
|
||||
|
||||
unless options[:unordered]
|
||||
# If we're logged in, we have to pay attention to our pinned settings
|
||||
if @user
|
||||
result = result.order(TopicQuery.order_nocategory_with_pinned_sql)
|
||||
else
|
||||
result = result.order(TopicQuery.order_nocategory_basic_bumped)
|
||||
end
|
||||
end
|
||||
|
||||
result = result.listable_topics.includes(category: :topic_only_relative_url)
|
||||
result = result.where('categories.name is null or categories.name <> ?', options[:exclude_category]).references(:categories) if options[:exclude_category]
|
||||
|
||||
category_id = nil
|
||||
if options[:category].present?
|
||||
category_id = options[:category].to_i
|
||||
if category_id == 0
|
||||
@ -244,6 +233,21 @@ class TopicQuery
|
||||
result = result.references(:categories)
|
||||
end
|
||||
|
||||
unless options[:unordered]
|
||||
# If we're logged in, we have to pay attention to our pinned settings
|
||||
if @user
|
||||
result = category_id.nil? ? result.order(TopicQuery.order_nocategory_with_pinned_sql) :
|
||||
result.order(TopicQuery.order_with_pinned_sql)
|
||||
else
|
||||
result = result.order(TopicQuery.order_nocategory_basic_bumped)
|
||||
end
|
||||
end
|
||||
|
||||
result = result.listable_topics.includes(category: :topic_only_relative_url)
|
||||
result = result.where('categories.name is null or categories.name <> ?', options[:exclude_category]).references(:categories) if options[:exclude_category]
|
||||
|
||||
|
||||
|
||||
result = result.limit(options[:per_page]) unless options[:limit] == false
|
||||
result = result.visible if options[:visible] || @user.nil? || @user.regular?
|
||||
result = result.where('topics.id <> ?', options[:except_topic_id]).references(:topics) if options[:except_topic_id]
|
||||
|
Loading…
Reference in New Issue
Block a user