From d13d42f3f6844aaab30ac702f2c5dcf66593d057 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20Hanol?= Date: Sat, 2 Aug 2014 00:34:58 +0200 Subject: [PATCH] FIX: automatic redirection to /top was a bit janky --- .../javascripts/discourse/routes/discovery_route.js | 1 + .../discourse/routes/discovery_top_routes.js | 10 ++++++++++ .../discourse/templates/discovery/top.js.handlebars | 2 +- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/discourse/routes/discovery_route.js b/app/assets/javascripts/discourse/routes/discovery_route.js index adf69acb576..798629cd6dc 100644 --- a/app/assets/javascripts/discourse/routes/discovery_route.js +++ b/app/assets/javascripts/discourse/routes/discovery_route.js @@ -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"); } }, diff --git a/app/assets/javascripts/discourse/routes/discovery_top_routes.js b/app/assets/javascripts/discourse/routes/discovery_top_routes.js index 118f1f3f75f..456e2c70934 100644 --- a/app/assets/javascripts/discourse/routes/discovery_top_routes.js +++ b/app/assets/javascripts/discourse/routes/discovery_top_routes.js @@ -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')); } diff --git a/app/assets/javascripts/discourse/templates/discovery/top.js.handlebars b/app/assets/javascripts/discourse/templates/discovery/top.js.handlebars index cbd9825e9e9..27fbfbfe7cd 100644 --- a/app/assets/javascripts/discourse/templates/discovery/top.js.handlebars +++ b/app/assets/javascripts/discourse/templates/discovery/top.js.handlebars @@ -1,5 +1,5 @@
- {{#if currentUser.should_be_redirected_to_top}} + {{#if currentUser.redirected_to_top_reason}}
{{currentUser.redirected_to_top_reason}}
{{/if}} {{#if content.yearly}}