mirror of
https://github.com/discourse/discourse.git
synced 2024-11-28 19:53:53 -06:00
FIX: Topic queryParams are removed from history state when scrolling. (#14881)
* Also fixed a bug where the queryParams are not removed when toggling between filters.
This commit is contained in:
parent
729043633e
commit
095255c8ec
@ -103,7 +103,17 @@ export default Controller.extend(bufferedProperty("model"), {
|
|||||||
),
|
),
|
||||||
|
|
||||||
updateQueryParams() {
|
updateQueryParams() {
|
||||||
this.setProperties(this.get("model.postStream.streamFilters"));
|
const filters = this.get("model.postStream.streamFilters");
|
||||||
|
|
||||||
|
if (Object.keys(filters).length > 0) {
|
||||||
|
this.setProperties(filters);
|
||||||
|
} else {
|
||||||
|
this.setProperties({
|
||||||
|
username_filters: null,
|
||||||
|
filter: null,
|
||||||
|
replies_to_post_number: null,
|
||||||
|
});
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@observes("model.title", "category")
|
@observes("model.title", "category")
|
||||||
|
@ -183,10 +183,32 @@ const TopicRoute = DiscourseRoute.extend({
|
|||||||
}
|
}
|
||||||
|
|
||||||
const topic = this.modelFor("topic");
|
const topic = this.modelFor("topic");
|
||||||
|
|
||||||
if (topic && currentPost) {
|
if (topic && currentPost) {
|
||||||
let postUrl = topic.get("url");
|
let postUrl;
|
||||||
|
|
||||||
if (currentPost > 1) {
|
if (currentPost > 1) {
|
||||||
postUrl += "/" + currentPost;
|
postUrl = topic.urlForPostNumber(currentPost);
|
||||||
|
} else {
|
||||||
|
postUrl = topic.url;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this._router.currentRoute.queryParams) {
|
||||||
|
let searchParams;
|
||||||
|
|
||||||
|
Object.entries(this._router.currentRoute.queryParams).map(
|
||||||
|
([key, value]) => {
|
||||||
|
if (!searchParams) {
|
||||||
|
searchParams = new URLSearchParams();
|
||||||
|
}
|
||||||
|
|
||||||
|
searchParams.append(key, value);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
if (searchParams) {
|
||||||
|
postUrl += `?${searchParams.toString()}`;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cancel(this.scheduledReplace);
|
cancel(this.scheduledReplace);
|
||||||
|
Loading…
Reference in New Issue
Block a user