mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 06:29:30 +08:00
BUGFIX: only redirect users top /top page once
This commit is contained in:
parent
561f7e0148
commit
39cc147138
|
@ -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
|
||||
|
|
|
@ -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"),
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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');
|
||||
|
|
|
@ -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">
|
||||
|
|
|
@ -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();
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue
Block a user