From b86198198fe904899f6b31edfbb7c05873a95625 Mon Sep 17 00:00:00 2001 From: Joffrey JAFFEUX Date: Fri, 7 Aug 2020 09:51:37 +0200 Subject: [PATCH] FIX: removes persistedQueryParams as it should work out of the box (#10394) This hack is only attempting to hide something which should have been working in core and for which we should provide a fix soon. Also it's not working as it should. --- .../discourse/app/components/d-navigation.js | 14 -------------- .../discourse/app/components/navigation-item.js | 8 -------- .../app/controllers/discovery-sortable.js | 7 ------- .../javascripts/discourse/app/models/nav-item.js | 3 --- 4 files changed, 32 deletions(-) diff --git a/app/assets/javascripts/discourse/app/components/d-navigation.js b/app/assets/javascripts/discourse/app/components/d-navigation.js index e253003a1dc..b8324f6e1b7 100644 --- a/app/assets/javascripts/discourse/app/components/d-navigation.js +++ b/app/assets/javascripts/discourse/app/components/d-navigation.js @@ -6,7 +6,6 @@ import FilterModeMixin from "discourse/mixins/filter-mode"; export default Component.extend(FilterModeMixin, { router: service(), - persistedQueryParams: null, tagName: "", @@ -62,25 +61,12 @@ export default Component.extend(FilterModeMixin, { @discourseComputed("filterType", "category", "noSubcategories") navItems(filterType, category, noSubcategories) { - let params; const currentRouteQueryParams = this.get("router.currentRoute.queryParams"); - if (this.persistedQueryParams && currentRouteQueryParams) { - const currentKeys = Object.keys(currentRouteQueryParams); - const discoveryKeys = Object.keys(this.persistedQueryParams); - const supportedKeys = currentKeys.filter( - i => discoveryKeys.indexOf(i) > 0 - ); - params = supportedKeys.reduce((object, key) => { - object[key] = currentRouteQueryParams[key]; - return object; - }, {}); - } return NavItem.buildList(category, { filterType, noSubcategories, currentRouteQueryParams, - persistedQueryParams: params, siteSettings: this.siteSettings }); }, diff --git a/app/assets/javascripts/discourse/app/components/navigation-item.js b/app/assets/javascripts/discourse/app/components/navigation-item.js index ea7b41bed78..3243a00ce87 100644 --- a/app/assets/javascripts/discourse/app/components/navigation-item.js +++ b/app/assets/javascripts/discourse/app/components/navigation-item.js @@ -51,14 +51,6 @@ export default Component.extend(FilterModeMixin, { } } - // ensures we keep discovery query params added through plugin api - if (content.persistedQueryParams) { - Object.keys(content.persistedQueryParams).forEach(key => { - const value = content.persistedQueryParams[key]; - queryParams.push(`${key}=${value}`); - }); - } - // To reset the "filter" sticky param, at least one query param is needed. // If no query param is present, add an empty one to ensure a ? is // appended to the URL. diff --git a/app/assets/javascripts/discourse/app/controllers/discovery-sortable.js b/app/assets/javascripts/discourse/app/controllers/discovery-sortable.js index 5972e5e25e9..fdaf34cd80f 100644 --- a/app/assets/javascripts/discourse/app/controllers/discovery-sortable.js +++ b/app/assets/javascripts/discourse/app/controllers/discovery-sortable.js @@ -1,7 +1,6 @@ import { alias } from "@ember/object/computed"; import { inject } from "@ember/controller"; import Controller from "@ember/controller"; -import DiscourseNavigation from "discourse/components/d-navigation"; // Just add query params here to have them automatically passed to topic list filters. export const queryParams = { @@ -37,12 +36,6 @@ export const addDiscoveryQueryParam = function(p, opts) { cOpts[p] = alias(`discoveryTopics.${p}`); cOpts["queryParams"] = Object.keys(queryParams); SortableController.reopen(cOpts); - - if (opts && opts.persisted) { - DiscourseNavigation.reopen({ - persistedQueryParams: queryParams - }); - } }; export default SortableController; diff --git a/app/assets/javascripts/discourse/app/models/nav-item.js b/app/assets/javascripts/discourse/app/models/nav-item.js index 3108a9fcb28..22c4fd8a31f 100644 --- a/app/assets/javascripts/discourse/app/models/nav-item.js +++ b/app/assets/javascripts/discourse/app/models/nav-item.js @@ -175,9 +175,6 @@ NavItem.reopenClass({ if (opts.currentRouteQueryParams) { args.currentRouteQueryParams = opts.currentRouteQueryParams; } - if (opts.persistedQueryParams) { - args.persistedQueryParams = opts.persistedQueryParams; - } if (opts.noSubcategories) { args.noSubcategories = true; }