mirror of
https://github.com/discourse/discourse.git
synced 2026-08-26 13:17:20 -05:00
FEATURE: do not redirect to top page when number of topis is low
This commit is contained in:
@@ -354,16 +354,18 @@ Discourse.User = Discourse.Model.extend({
|
||||
@type {String}
|
||||
**/
|
||||
homepage: function() {
|
||||
// top is the default for:
|
||||
// when there are enough topics, /top is the default for
|
||||
// - new users
|
||||
// - long-time-no-see user (ie. > 1 month)
|
||||
if (Discourse.SiteSettings.top_menu.indexOf("top") >= 0) {
|
||||
if (this.get("trust_level") === 0 || !this.get("hasBeenSeenInTheLastMonth")) {
|
||||
return "top";
|
||||
if (Discourse.Site.currentProp("has_enough_topic_to_redirect_to_top_page")) {
|
||||
if (Discourse.SiteSettings.top_menu.indexOf("top") >= 0) {
|
||||
if (this.get("trust_level") === 0 || !this.get("hasBeenSeenInTheLastMonth")) {
|
||||
return "top";
|
||||
}
|
||||
}
|
||||
}
|
||||
return Discourse.Utilities.defaultHomepage();
|
||||
}.property("trust_level", "hasBeenSeenInTheLastMonth"),
|
||||
}.property("trust_level", "hasBeenSeenInTheLastMonth", "Discourse.Site.has_enough_topic_to_redirect_to_top_page"),
|
||||
|
||||
updateMutedCategories: function() {
|
||||
this.set("mutedCategories", Discourse.Category.findByIds(this.muted_category_ids));
|
||||
|
||||
@@ -9,7 +9,8 @@ class SiteSerializer < ApplicationSerializer
|
||||
:top_menu_items,
|
||||
:anonymous_top_menu_items,
|
||||
:uncategorized_category_id, # this is hidden so putting it here
|
||||
:is_readonly
|
||||
:is_readonly,
|
||||
:has_enough_topic_to_redirect_to_top_page
|
||||
|
||||
has_many :categories, serializer: BasicCategorySerializer, embed: :objects
|
||||
has_many :post_action_types, embed: :objects
|
||||
@@ -50,4 +51,12 @@ class SiteSerializer < ApplicationSerializer
|
||||
Discourse.readonly_mode?
|
||||
end
|
||||
|
||||
def has_enough_topic_to_redirect_to_top_page
|
||||
Topic.listable_topics
|
||||
.visible
|
||||
.includes(:category).references(:category)
|
||||
.where('COALESCE(categories.topic_id, 0) <> topics.id')
|
||||
.count > SiteSetting.topics_per_period_in_top_page
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user