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() { jumpTop() {
DiscourseURL.routeTo(this.get("model.firstPostUrl"), { DiscourseURL.routeTo(this.get("model.firstPostUrl"), {
skipIfOnScreen: false, skipIfOnScreen: false,
keepFilter: true,
}); });
}, },
@ -764,6 +765,7 @@ export default Controller.extend(bufferedProperty("model"), {
DiscourseURL.routeTo(this.get("model.lastPostUrl"), { DiscourseURL.routeTo(this.get("model.lastPostUrl"), {
skipIfOnScreen: false, skipIfOnScreen: false,
jumpEnd, jumpEnd,
keepFilter: true,
}); });
}, },
@ -774,6 +776,7 @@ export default Controller.extend(bufferedProperty("model"), {
); );
DiscourseURL.routeTo(this.get("model.lastPostUrl"), { DiscourseURL.routeTo(this.get("model.lastPostUrl"), {
jumpEnd: true, jumpEnd: true,
keepFilter: true,
}); });
}, },
@ -1163,11 +1166,18 @@ export default Controller.extend(bufferedProperty("model"), {
const post = postStream.findLoadedPost(postId); const post = postStream.findLoadedPost(postId);
if (post) { if (post) {
DiscourseURL.routeTo(topic.urlForPostNumber(post.get("post_number"))); DiscourseURL.routeTo(topic.urlForPostNumber(post.get("post_number")), {
keepFilter: true,
});
} else { } else {
// need to load it // need to load it
postStream.findPostsByIds([postId]).then((arr) => { 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.nearPost = topicController.get("model.highest_post_number");
} }
if (!routeOpts.keepFilter) {
opts.cancelFilter = true; opts.cancelFilter = true;
}
postStream.refresh(opts).then(() => { postStream.refresh(opts).then(() => {
const closest = postStream.closestPostNumberFor(opts.nearPost || 1); const closest = postStream.closestPostNumberFor(opts.nearPost || 1);

View File

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