BUGFIX: only redirect users top /top page once

This commit is contained in:
Régis Hanol 2014-04-21 18:43:44 +02:00
parent 561f7e0148
commit 39cc147138
6 changed files with 10 additions and 38 deletions

View File

@ -177,7 +177,7 @@ Discourse.URL = Em.Object.createWithMixins({
@param {String} path the path we're navigating to
**/
navigatedToHome: function(oldPath, path) {
var homepage = Discourse.User.current() ? Discourse.User.currentProp('homepage') : Discourse.Utilities.defaultHomepage();
var homepage = Discourse.Utilities.defaultHomepage();
if (path === "/" && (oldPath === "/" || oldPath === "/" + homepage)) {
// refresh the list

View File

@ -389,16 +389,6 @@ Discourse.User = Discourse.Model.extend({
});
},
/**
Homepage of the user
@property homepage
@type {String}
**/
homepage: function() {
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));
}.observes("muted_category_ids"),

View File

@ -53,8 +53,7 @@ Discourse.Route.buildRoutes(function() {
this.route('category', { path: '/category/:parentSlug/:slug' });
// homepage
var homepage = Discourse.User.current() ? Discourse.User.currentProp('homepage') : Discourse.Utilities.defaultHomepage();
this.route(homepage, { path: '/' });
this.route(Discourse.Utilities.defaultHomepage(), { path: '/' });
});
this.resource('group', { path: '/groups/:name' }, function() {

View File

@ -9,6 +9,13 @@
**/
Discourse.DiscoveryRoute = Discourse.Route.extend(Discourse.ScrollTop, Discourse.OpenComposer, {
beforeModel: function(transition) {
if (transition.targetName.indexOf("discovery.top") === -1 &&
Discourse.User.currentProp("should_be_redirected_to_top")) {
this.transitionTo("discovery.top");
}
},
actions: {
loading: function() {
var controller = this.controllerFor('discovery');

View File

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

View File

@ -25,25 +25,3 @@ test("isAllowedToUploadAFile", function() {
user.setProperties({ admin: false, moderator: true });
ok(user.isAllowedToUploadAFile("image"), "moderator can always upload a file");
});
test("homepage", function() {
var user = Discourse.User.create({ should_be_redirected_to_top: false });
var defaultHomepage = Discourse.Utilities.defaultHomepage();
equal(user.get("homepage"), defaultHomepage, "user's homepage is default when not redirected");
user.set("should_be_redirected_to_top", true);
equal(user.get("homepage"), "top", "user's homepage is top when redirected");
});
asyncTestDiscourse("findByUsername", function() {
expect(3);
Discourse.User.findByUsername('eviltrout').then(function (user) {
present(user);
equal(user.get('username'), 'eviltrout', 'it has the correct username');
equal(user.get('name'), 'Robin Ward', 'it has the full name since it has details');
start();
});
});