From f101408d036c78d487d99f2810063783e6a5b59d Mon Sep 17 00:00:00 2001 From: Sam Date: Tue, 23 Jun 2015 12:45:41 +1000 Subject: [PATCH] FEATURE: on mobile display a rollup of unread and new on latest --- app/assets/javascripts/discourse/models/nav_item.js | 8 +++++++- .../discourse/models/topic-tracking-state.js.es6 | 7 +++++++ config/locales/client.en.yml | 5 ++++- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/discourse/models/nav_item.js b/app/assets/javascripts/discourse/models/nav_item.js index 18571d2de..0ea27df11 100644 --- a/app/assets/javascripts/discourse/models/nav_item.js +++ b/app/assets/javascripts/discourse/models/nav_item.js @@ -12,7 +12,13 @@ Discourse.NavItem = Discourse.Model.extend({ displayName: function() { var categoryName = this.get('categoryName'), name = this.get('name'), - extra = { count: this.get('count') || 0 }; + count = this.get('count') || 0; + + if (name === 'latest' && !Discourse.Mobile.mobileView) { + count = 0; + } + + var extra = { count: count }; if (categoryName) { name = 'category'; diff --git a/app/assets/javascripts/discourse/models/topic-tracking-state.js.es6 b/app/assets/javascripts/discourse/models/topic-tracking-state.js.es6 index 036fac5a6..051a7b032 100644 --- a/app/assets/javascripts/discourse/models/topic-tracking-state.js.es6 +++ b/app/assets/javascripts/discourse/models/topic-tracking-state.js.es6 @@ -266,6 +266,12 @@ const TopicTrackingState = Discourse.Model.extend({ }, lookupCount(name, category){ + + if (name === "latest") { + return this.lookupCount("new", category) + + this.lookupCount("unread", category); + } + let categoryName = category ? Em.get(category, "name") : null; if(name === "new") { return this.countNew(categoryName); @@ -278,6 +284,7 @@ const TopicTrackingState = Discourse.Model.extend({ } } }, + loadStates(data) { // not exposed const states = this.states; diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index 6d49c48c0..8736a0397 100644 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -1567,7 +1567,10 @@ en: with_topics: "%{filter} topics" with_category: "%{filter} %{category} topics" latest: - title: "Latest" + title: + zero: "Latest" + one: "Latest (1)" + other: "Latest ({{count}})" help: "topics with recent posts" hot: title: "Hot"