FIX: automatic redirection to /top was a bit janky

This commit is contained in:
Régis Hanol 2014-08-02 00:34:58 +02:00
parent b368667703
commit d13d42f3f6
3 changed files with 12 additions and 1 deletions

View File

@ -14,6 +14,7 @@ Discourse.DiscoveryRoute = Discourse.Route.extend(Discourse.ScrollTop, Discourse
beforeModel: function(transition) {
if (transition.targetName.indexOf("discovery.top") === -1 &&
Discourse.User.currentProp("should_be_redirected_to_top")) {
Discourse.User.currentProp("should_be_redirected_to_top", false);
this.transitionTo("discovery.top");
}
},

View File

@ -39,6 +39,11 @@ Discourse.DiscoveryTopRoute = Discourse.Route.extend(Discourse.OpenComposer, {
actions: {
willTransition: function () {
Discourse.User.currentProp("should_be_redirected_to_top", false);
Discourse.User.currentProp("redirected_to_top_reason", null);
},
createTopic: function() {
this.openComposer(this.controllerFor('discovery/top'));
}
@ -110,6 +115,11 @@ Discourse.DiscoveryTopCategoryRoute = Discourse.Route.extend(Discourse.OpenCompo
actions: {
willTransition: function () {
Discourse.User.currentProp("should_be_redirected_to_top", false);
Discourse.User.currentProp("redirected_to_top_reason", null);
},
createTopic: function() {
this.openComposer(this.controllerFor('discovery/top'));
}

View File

@ -1,5 +1,5 @@
<div class="top-lists">
{{#if currentUser.should_be_redirected_to_top}}
{{#if currentUser.redirected_to_top_reason}}
<div class="alert alert-info">{{currentUser.redirected_to_top_reason}}</div>
{{/if}}
{{#if content.yearly}}