FIX: Keep current filter while navigating posts in a topic (#12620)

This commit is contained in:
Penar Musaraj 2021-04-06 15:00:25 -04:00 committed by GitHub
parent 75a0d9aa01
commit 34596beb52
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 4 deletions

View File

@ -754,6 +754,7 @@ export default Controller.extend(bufferedProperty("model"), {
jumpTop() {
DiscourseURL.routeTo(this.get("model.firstPostUrl"), {
skipIfOnScreen: false,
keepFilter: true,
});
},
@ -764,6 +765,7 @@ export default Controller.extend(bufferedProperty("model"), {
DiscourseURL.routeTo(this.get("model.lastPostUrl"), {
skipIfOnScreen: false,
jumpEnd,
keepFilter: true,
});
},
@ -774,6 +776,7 @@ export default Controller.extend(bufferedProperty("model"), {
);
DiscourseURL.routeTo(this.get("model.lastPostUrl"), {
jumpEnd: true,
keepFilter: true,
});
},
@ -1163,11 +1166,18 @@ export default Controller.extend(bufferedProperty("model"), {
const post = postStream.findLoadedPost(postId);
if (post) {
DiscourseURL.routeTo(topic.urlForPostNumber(post.get("post_number")));
DiscourseURL.routeTo(topic.urlForPostNumber(post.get("post_number")), {
keepFilter: true,
});
} else {
// need to load it
postStream.findPostsByIds([postId]).then((arr) => {
DiscourseURL.routeTo(topic.urlForPostNumber(arr[0].get("post_number")));
DiscourseURL.routeTo(
topic.urlForPostNumber(arr[0].get("post_number")),
{
keepFilter: true,
}
);
});
}
},

View File

@ -370,7 +370,9 @@ const DiscourseURL = EmberObject.extend({
opts.nearPost = topicController.get("model.highest_post_number");
}
opts.cancelFilter = true;
if (!routeOpts.keepFilter) {
opts.cancelFilter = true;
}
postStream.refresh(opts).then(() => {
const closest = postStream.closestPostNumberFor(opts.nearPost || 1);

View File

@ -223,7 +223,9 @@ export default createWidget("header-topic-info", {
jumpToTopPost() {
const topic = this.attrs.topic;
if (topic) {
DiscourseURL.routeTo(topic.get("firstPostUrl"));
DiscourseURL.routeTo(topic.get("firstPostUrl"), {
keepFilter: true,
});
}
},
});