Fix unnecessary ?near=1 in some URLs

This commit is contained in:
Toby Zerner 2015-08-13 13:06:55 +09:30
parent f9c5d0f2d7
commit 7e37cf5568
2 changed files with 6 additions and 4 deletions

View File

@ -65,8 +65,10 @@ export default class DiscussionPage extends mixin(Component, evented) {
if (m.route.param('id') === this.discussion.id()) { if (m.route.param('id') === this.discussion.id()) {
e.preventDefault(); e.preventDefault();
if (Number(m.route.param('near')) !== Number(this.near)) { const near = Number(m.route.param('near')) || 1;
this.stream.goToNumber(m.route.param('near') || 1);
if (near !== Number(this.near)) {
this.stream.goToNumber(near);
} }
this.near = null; this.near = null;

View File

@ -35,10 +35,10 @@ export default function(app) {
* @return {String} * @return {String}
*/ */
app.route.discussion = (discussion, near) => { app.route.discussion = (discussion, near) => {
return app.route(near ? 'discussion.near' : 'discussion', { return app.route(near > 1 ? 'discussion.near' : 'discussion', {
id: discussion.id(), id: discussion.id(),
slug: discussion.slug(), slug: discussion.slug(),
near: near near: near > 1 ? near : undefined
}); });
}; };