DEV: Use new filterType property where possible

DEV: Use new filterType property where possible

diff --git a/app/assets/javascripts/discourse/components/d-navigation.js.es6 b/app/assets/javascripts/discourse/components/d-navigation.js.es6
index ea0b2fddc8..041e21e4a8 100644
--- a/app/assets/javascripts/discourse/components/d-navigation.js.es6
+++ b/app/assets/javascripts/discourse/components/d-navigation.js.es6
@@ -28,17 +28,8 @@ export default Component.extend(FilterModeMixin, {
   @discourseComputed("category.can_edit")
   showCategoryEdit: canEdit => canEdit,
 
-  @discourseComputed("filterMode", "category", "noSubcategories")
-  navItems(filterMode, category, noSubcategories) {
-    const filterModeParts = filterMode.split("/");
-    if (
-      filterModeParts.length >= 2 &&
-      filterModeParts[filterModeParts.length - 2] === "top"
-    ) {
-      filterModeParts.pop();
-      filterMode = filterModeParts.join("/");
-    }
-
+  @discourseComputed("filterType", "category", "noSubcategories")
+  navItems(filterType, category, noSubcategories) {
     let params;
     const currentRouteQueryParams = this.get("router.currentRoute.queryParams");
     if (this.persistedQueryParams && currentRouteQueryParams) {
@@ -54,7 +45,7 @@ export default Component.extend(FilterModeMixin, {
     }
 
     return NavItem.buildList(category, {
-      filterMode,
+      filterType,
       noSubcategories,
       persistedQueryParams: params
     });
diff --git a/app/assets/javascripts/discourse/components/navigation-bar.js.es6 b/app/assets/javascripts/discourse/components/navigation-bar.js.es6
index b3157f5748..6051726395 100644
--- a/app/assets/javascripts/discourse/components/navigation-bar.js.es6
+++ b/app/assets/javascripts/discourse/components/navigation-bar.js.es6
@@ -18,21 +18,11 @@ export default Component.extend(FilterModeMixin, {
     this.set("connectors", renderedConnectorsFor("extra-nav-item", null, this));
   },
 
-  @discourseComputed("filterMode", "navItems")
-  selectedNavItem(filterMode, navItems) {
-    const filterModeParts = filterMode.split("/");
-    if (
-      filterModeParts.length >= 2 &&
-      filterModeParts[filterModeParts.length - 2] === "top"
-    ) {
-      filterModeParts.pop();
-      filterMode = filterModeParts.join("/");
-    }
-
+  @discourseComputed("filterType", "navItems")
+  selectedNavItem(filterType, navItems) {
     let item = navItems.find(i => i.active === true);
 
-    item =
-      item || navItems.find(i => i.get("filterMode").indexOf(filterMode) === 0);
+    item = item || navItems.find(i => i.get("filterType") === filterType);
 
     if (!item) {
       let connectors = this.connectors;
@@ -45,7 +35,7 @@ export default Component.extend(FilterModeMixin, {
             typeof (c.connectorClass.displayName === "function")
           ) {
             let path = c.connectorClass.path(category);
-            if (path.indexOf(filterMode) > 0) {
+            if (path.indexOf(filterType) > 0) {
               item = {
                 displayName: c.connectorClass.displayName()
               };
diff --git a/app/assets/javascripts/discourse/components/navigation-item.js.es6 b/app/assets/javascripts/discourse/components/navigation-item.js.es6
index 3ed9740c6b..90c56da1c9 100644
--- a/app/assets/javascripts/discourse/components/navigation-item.js.es6
+++ b/app/assets/javascripts/discourse/components/navigation-item.js.es6
@@ -17,15 +17,12 @@ export default Component.extend(
     hidden: false,
     rerenderTriggers: ["content.count"],
 
-    @discourseComputed("content.filterMode", "filterMode", "content.active")
-    active(contentFilterMode, filterMode, active) {
+    @discourseComputed("content.filterType", "filterType", "content.active")
+    active(contentFilterType, filterType, active) {
       if (active !== undefined) {
         return active;
       }
-      return (
-        contentFilterMode === filterMode ||
-        filterMode.indexOf(contentFilterMode) === 0
-      );
+      return contentFilterType === filterType;
     },
 
     buildBuffer(buffer) {
diff --git a/app/assets/javascripts/discourse/controllers/tags-show.js.es6 b/app/assets/javascripts/discourse/controllers/tags-show.js.es6
index 26aa9d9684..34aa673c96 100644
--- a/app/assets/javascripts/discourse/controllers/tags-show.js.es6
+++ b/app/assets/javascripts/discourse/controllers/tags-show.js.es6
@@ -65,11 +65,11 @@ export default Controller.extend(BulkTopicSelection, FilterModeMixin, {
     "q"
   ],
 
-  @discourseComputed("category", "tag.id", "filterMode", "noSubcategories")
-  navItems(category, tagId, filterMode, noSubcategories) {
+  @discourseComputed("category", "tag.id", "filterType", "noSubcategories")
+  navItems(category, tagId, filterType, noSubcategories) {
     return NavItem.buildList(category, {
       tagId,
-      filterMode,
+      filterType,
       noSubcategories
     });
   },

GitHub sha: 57624983

1 Like

FIX: Use correct variable name (#49)