mirror of
https://github.com/discourse/discourse.git
synced 2026-08-26 21:27:16 -05:00
Support for a /last route to go to the last post in a topic.
This commit is contained in:
@@ -69,7 +69,11 @@ Discourse.Topic = Discourse.Model.extend({
|
||||
urlForPostNumber: function(postNumber) {
|
||||
var url = this.get('url');
|
||||
if (postNumber && (postNumber > 1)) {
|
||||
url += "/" + postNumber;
|
||||
if (postNumber >= this.get('highest_post_number')) {
|
||||
url += "/last";
|
||||
} else {
|
||||
url += "/" + postNumber;
|
||||
}
|
||||
}
|
||||
return url;
|
||||
},
|
||||
|
||||
@@ -33,6 +33,9 @@ Discourse.TopicFromParamsRoute = Discourse.Route.extend({
|
||||
var topicController = this.controllerFor('topic'),
|
||||
composerController = this.controllerFor('composer');
|
||||
|
||||
// I sincerely hope no topic gets this many posts
|
||||
if (params.nearPost === "last") { params.nearPost = 999999999; }
|
||||
|
||||
postStream.refresh(params).then(function () {
|
||||
// The post we requested might not exist. Let's find the closest post
|
||||
var closest = postStream.closestPostNumberFor(params.nearPost) || 1;
|
||||
|
||||
Reference in New Issue
Block a user