diff --git a/app/assets/javascripts/discourse.js b/app/assets/javascripts/discourse.js index f0f8309a79d..228db475c01 100644 --- a/app/assets/javascripts/discourse.js +++ b/app/assets/javascripts/discourse.js @@ -42,15 +42,17 @@ Discourse = Ember.Application.createWithMixins({ } title += Discourse.SiteSettings.title; $('title').text(title); - if (!this.get('hasFocus') && this.get('notify')) { - title = "(*) " + title; + + var notifyCount = this.get('notifyCount'); + if (notifyCount > 0) { + title = "(" + notifyCount + ") " + title; } // chrome bug workaround see: http://stackoverflow.com/questions/2952384/changing-the-window-title-when-focussing-the-window-doesnt-work-in-chrome window.setTimeout(function() { document.title = "."; document.title = title; }, 200); - }.observes('title', 'hasFocus', 'notify'), + }.observes('title', 'hasFocus', 'notifyCount'), // The classes of buttons to show on a post postButtons: function() { @@ -59,8 +61,8 @@ Discourse = Ember.Application.createWithMixins({ }); }.property('Discourse.SiteSettings.post_menu'), - notifyTitle: function() { - this.set('notify', true); + notifyTitle: function(count) { + this.set('notifyCount', count); }, openComposer: function(opts) { diff --git a/app/assets/javascripts/discourse/controllers/list_topics_controller.js b/app/assets/javascripts/discourse/controllers/list_topics_controller.js index 6dc6df181cc..e864e9c5e34 100644 --- a/app/assets/javascripts/discourse/controllers/list_topics_controller.js +++ b/app/assets/javascripts/discourse/controllers/list_topics_controller.js @@ -80,16 +80,6 @@ Discourse.ListTopicsController = Discourse.ObjectController.extend({ } }.property('allLoaded', 'topics.length'), - insertedCount: function() { - var insertedLength = this.get('inserted.length'); - if (!insertedLength) return 0; - return insertedLength; - }.property('inserted.length'), - - rollUp: function() { - return this.get('insertedCount') > Discourse.SiteSettings.new_topics_rollup; - }.property('insertedCount'), - loadMore: function() { this.set('loadingMore', true); var listTopicsController = this; diff --git a/app/assets/javascripts/discourse/controllers/topic_controller.js b/app/assets/javascripts/discourse/controllers/topic_controller.js index 7231e2601bb..42b4042ee74 100644 --- a/app/assets/javascripts/discourse/controllers/topic_controller.js +++ b/app/assets/javascripts/discourse/controllers/topic_controller.js @@ -347,7 +347,6 @@ Discourse.TopicController = Discourse.ObjectController.extend(Discourse.Selected topic.set('highest_post_number', data.post_number); topic.set('last_poster', data.user); topic.set('last_posted_at', data.created_at); - Discourse.notifyTitle(); }); }, diff --git a/app/assets/javascripts/discourse/routes/discourse_route.js b/app/assets/javascripts/discourse/routes/discourse_route.js index 09e88665b74..63ac2817602 100644 --- a/app/assets/javascripts/discourse/routes/discourse_route.js +++ b/app/assets/javascripts/discourse/routes/discourse_route.js @@ -24,6 +24,8 @@ Discourse.Route = Em.Route.extend({ $('header ul.icons li').removeClass('active'); $('[data-toggle="dropdown"]').parent().removeClass('open'); + Discourse.set('notifyCount',0); + var hideDropDownFunction = $('html').data('hide-dropdown'); if (hideDropDownFunction) return hideDropDownFunction(); } diff --git a/app/assets/javascripts/discourse/views/list/list_topics_view.js b/app/assets/javascripts/discourse/views/list/list_topics_view.js index 6cc8c8e390b..c6ab8d4f556 100644 --- a/app/assets/javascripts/discourse/views/list/list_topics_view.js +++ b/app/assets/javascripts/discourse/views/list/list_topics_view.js @@ -51,8 +51,13 @@ Discourse.ListTopicsView = Discourse.View.extend(Discourse.Scrolling, { } }.property('list.topics.@each','topicTrackingState.hasIncoming'), + updateTitle: function(){ + Discourse.notifyTitle(this.get('topicTrackingState.incomingCount')); + }.observes('topicTrackingState.incomingCount'), + loadMore: function() { var listTopicsView = this; + Discourse.notifyTitle(0); listTopicsView.get('controller').loadMore().then(function (hasMoreResults) { Em.run.schedule('afterRender', function() { listTopicsView.saveScrollPos();