diff --git a/app/assets/javascripts/discourse/controllers/list_controller.js b/app/assets/javascripts/discourse/controllers/list_controller.js index edf9765fdeb..072918c9b32 100644 --- a/app/assets/javascripts/discourse/controllers/list_controller.js +++ b/app/assets/javascripts/discourse/controllers/list_controller.js @@ -7,32 +7,34 @@ @module Discourse **/ Discourse.ListController = Discourse.Controller.extend({ - categoryBinding: 'topicList.category', + categoryBinding: "topicList.category", canCreateCategory: false, canCreateTopic: false, - needs: ['composer', 'modal', 'listTopics'], + needs: ["composer", "modal", "listTopics"], availableNavItems: function() { var loggedOn = !!Discourse.User.current(); + var category = this.get("category"); return Discourse.SiteSettings.top_menu.split("|").map(function(i) { return Discourse.NavItem.fromText(i, { - loggedOn: loggedOn + loggedOn: loggedOn, + category: category }); }).filter(function(i) { - return i !== null; + return i !== null && !(category && i.get("name") === "categories"); }); - }.property(), + }.property("category"), createTopicText: function() { - if (this.get('category.name')) { + if (this.get("category.name")) { return I18n.t("topic.create_in", { - categoryName: this.get('category.name') + categoryName: this.get("category.name") }); } else { return I18n.t("topic.create"); } - }.property('category.name'), + }.property("category.name"), /** Refresh our current topic list diff --git a/app/assets/javascripts/discourse/models/nav_item.js b/app/assets/javascripts/discourse/models/nav_item.js index c4df6c42dc9..b5a4de47c35 100644 --- a/app/assets/javascripts/discourse/models/nav_item.js +++ b/app/assets/javascripts/discourse/models/nav_item.js @@ -42,7 +42,7 @@ Discourse.NavItem = Discourse.Model.extend({ count: function() { var state = this.get('topicTrackingState'); if (state) { - return state.lookupCount(this.get('name')); + return state.lookupCount(this.get('name'), this.get('category')); } }.property('topicTrackingState.messageCount'), @@ -71,7 +71,8 @@ Discourse.NavItem.reopenClass({ opts = { name: name, hasIcon: name === "unread" || name === "favorited", - filters: split.splice(1) + filters: split.splice(1), + category: opts.category }; return Discourse.NavItem.create(opts); diff --git a/app/assets/javascripts/discourse/models/topic_tracking_state.js b/app/assets/javascripts/discourse/models/topic_tracking_state.js index 882d0dd6af3..90584c7839a 100644 --- a/app/assets/javascripts/discourse/models/topic_tracking_state.js +++ b/app/assets/javascripts/discourse/models/topic_tracking_state.js @@ -159,15 +159,16 @@ Discourse.TopicTrackingState = Discourse.Model.extend({ return count; }, - lookupCount: function(name){ + lookupCount: function(name, category){ + var categoryName = Em.get(category, "name"); if(name==="new") { - return this.countNew(); + return this.countNew(categoryName); } else if(name==="unread") { - return this.countUnread(); + return this.countUnread(categoryName); } else { - var category = name.split("/")[1]; - if(category) { - return this.countCategory(category); + categoryName = name.split("/")[1]; + if(categoryName) { + return this.countCategory(categoryName); } } },