mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
BUGFIX: don't show redirect reason if you aren't redirected
Move the redirect to top page logic server-side and make sure the reason is not shown when top is not in the navigation menu (top_menu).
This commit is contained in:
@@ -19,20 +19,5 @@ Discourse.DiscoveryTopController = Discourse.DiscoveryController.extend({
|
||||
}
|
||||
},
|
||||
|
||||
redirectedToTopPageReason: function() {
|
||||
// no need for a reason if the default homepage is 'top'
|
||||
if (Discourse.Utilities.defaultHomepage() === 'top') { return null; }
|
||||
// check if the user is authenticated
|
||||
if (Discourse.User.current()) {
|
||||
if (Discourse.User.currentProp('trust_level') === 0) {
|
||||
return I18n.t('filters.top.redirect_reasons.new_user');
|
||||
} else if (!Discourse.User.currentProp('hasBeenSeenInTheLastMonth')) {
|
||||
return I18n.t('filters.top.redirect_reasons.not_seen_in_a_month');
|
||||
}
|
||||
}
|
||||
// no reason detected
|
||||
return null;
|
||||
}.property(),
|
||||
|
||||
hasDisplayedAllTopLists: Em.computed.and('content.yearly', 'content.monthly', 'content.weekly', 'content.daily')
|
||||
});
|
||||
|
||||
@@ -373,16 +373,6 @@ Discourse.User = Discourse.Model.extend({
|
||||
});
|
||||
},
|
||||
|
||||
hasNotBeenSeenInTheLastMonth: function() {
|
||||
return moment().diff(moment(this.get("last_seen_at")), "month", true) >= 1.0;
|
||||
}.property("last_seen_at"),
|
||||
|
||||
shouldBeRedirectToTopPage: function() {
|
||||
if (this.get("trust_level") > 0) { return false; }
|
||||
var duration = Discourse.SiteSettings.redirect_new_users_to_top_page_duration;
|
||||
return moment().diff(moment(this.get("created_at")), "days", true) < duration;
|
||||
}.property("trust_level", "created_at"),
|
||||
|
||||
/**
|
||||
Homepage of the user
|
||||
|
||||
@@ -390,18 +380,8 @@ Discourse.User = Discourse.Model.extend({
|
||||
@type {String}
|
||||
**/
|
||||
homepage: function() {
|
||||
// when there are enough topics, /top is the default for
|
||||
// - new users
|
||||
// - long-time-no-see user (ie. > 1 month)
|
||||
if (Discourse.Site.currentProp("has_enough_topic_to_redirect_to_top_page")) {
|
||||
if (Discourse.SiteSettings.top_menu.indexOf("top") >= 0) {
|
||||
if (this.get("shouldBeRedirectToTopPage") || this.get("hasNotBeenSeenInTheLastMonth")) {
|
||||
return "top";
|
||||
}
|
||||
}
|
||||
}
|
||||
return Discourse.Utilities.defaultHomepage();
|
||||
}.property("shouldBeRedirectToTopPage", "hasNotBeenSeenInTheLastMonth"),
|
||||
return this.get("should_be_redirected_to_top") ? "top" : Discourse.Utilities.defaultHomepage();
|
||||
}.property("should_be_redirected_to_top"),
|
||||
|
||||
updateMutedCategories: function() {
|
||||
this.set("mutedCategories", Discourse.Category.findByIds(this.muted_category_ids));
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<div class="top-lists">
|
||||
{{#if redirectedToTopPageReason}}
|
||||
{{#if currentUser.should_be_redirected_to_top}}
|
||||
<div class="alert alert-info">
|
||||
{{redirectedToTopPageReason}}
|
||||
{{currentUser.redirected_to_top_reason}}
|
||||
</div>
|
||||
{{/if}}
|
||||
{{#if content.yearly}}
|
||||
|
||||
Reference in New Issue
Block a user