FIX: When finding a topic by slug only, use replaceState

This commit is contained in:
Robin Ward 2015-07-10 15:56:23 -04:00
parent 284b86cf5d
commit ecd48a4b35
2 changed files with 12 additions and 13 deletions

View File

@ -104,11 +104,8 @@ Discourse.URL = Ember.Object.createWithMixins({
It contains the logic necessary to route within a topic using replaceState to It contains the logic necessary to route within a topic using replaceState to
keep the history intact. keep the history intact.
@method routeTo
@param {String} path The path we are routing to.
**/ **/
routeTo: function(path) { routeTo: function(path, opts) {
if (Em.isEmpty(path)) { return; } if (Em.isEmpty(path)) { return; }
if (Discourse.get('requiresRefresh')) { if (Discourse.get('requiresRefresh')) {
@ -166,7 +163,7 @@ Discourse.URL = Ember.Object.createWithMixins({
this.appEvents.trigger('url:refresh'); this.appEvents.trigger('url:refresh');
} }
return this.handleURL(path); return this.handleURL(path, opts);
}, },
rewrite: function(regexp, replacement) { rewrite: function(regexp, replacement) {
@ -310,17 +307,19 @@ Discourse.URL = Ember.Object.createWithMixins({
}, },
/** /**
@private
Be wary of looking up the router. In this case, we have links in our Be wary of looking up the router. In this case, we have links in our
HTML, say form compiled markdown posts, that need to be routed. HTML, say form compiled markdown posts, that need to be routed.
@method handleURL
@param {String} path the url to handle
**/ **/
handleURL: function(path) { handleURL: function(path, opts) {
opts = opts || {};
var router = this.get('router'); var router = this.get('router');
router.router.updateURL(path);
if (opts.replaceURL) {
this.replaceState(path);
} else {
router.router.updateURL(path);
}
var split = path.split('#'), var split = path.split('#'),
elementId; elementId;

View File

@ -6,6 +6,6 @@ export default Discourse.Route.extend({
}, },
afterModel: function(result) { afterModel: function(result) {
Discourse.URL.routeTo(result.url); Discourse.URL.routeTo(result.url, { replaceURL: true });
} }
}); });