diff --git a/app/assets/javascripts/discourse/controllers/list_controller.js b/app/assets/javascripts/discourse/controllers/list_controller.js index b69e37ede0c..22f017f8ca6 100644 --- a/app/assets/javascripts/discourse/controllers/list_controller.js +++ b/app/assets/javascripts/discourse/controllers/list_controller.js @@ -47,7 +47,7 @@ Discourse.ListController = Discourse.Controller.extend({ draft_key: items.draft_key, draft_sequence: items.draft_sequence }); - if(trackingState) { + if(trackingState) { trackingState.sync(items, filterMode); trackingState.trackIncoming(filterMode); } diff --git a/app/assets/javascripts/discourse/models/topic_tracking_state.js b/app/assets/javascripts/discourse/models/topic_tracking_state.js index 09a692fb53f..94a69421a9b 100644 --- a/app/assets/javascripts/discourse/models/topic_tracking_state.js +++ b/app/assets/javascripts/discourse/models/topic_tracking_state.js @@ -17,9 +17,9 @@ Discourse.TopicTrackingState = Discourse.Model.extend({ tracker.removeTopic(data.topic_id); } - if (data.message_type === "new_topic" || data.message_type === "unread" || data.message_type == "read") { - tracker.states["t" + data.topic_id] = data.payload; + if (data.message_type === "new_topic" || data.message_type === "unread" || data.message_type === "read") { tracker.notify(data); + tracker.states["t" + data.topic_id] = data.payload; } tracker.incrementMessageCount(); @@ -38,6 +38,12 @@ Discourse.TopicTrackingState = Discourse.Model.extend({ if ((this.filter === "latest" || this.filter === "new") && data.message_type === "new_topic" ) { this.newIncoming.push(data.topic_id); } + if (this.filter === "unread" && data.message_type === "unread") { + var old = this.states["t" + data.topic_id]; + if(!old) { + this.newIncoming.push(data.topic_id); + } + } this.set("incomingCount", this.newIncoming.length); }, 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 f48d3d82451..6cc8c8e390b 100644 --- a/app/assets/javascripts/discourse/views/list/list_topics_view.js +++ b/app/assets/javascripts/discourse/views/list/list_topics_view.js @@ -49,7 +49,7 @@ Discourse.ListTopicsView = Discourse.View.extend(Discourse.Scrolling, { if(topics) { return this.get('list.topics').length > 0 || this.get('topicTrackingState.hasIncoming'); } - }.property('list.topics','topicTrackingState.hasIncoming'), + }.property('list.topics.@each','topicTrackingState.hasIncoming'), loadMore: function() { var listTopicsView = this; diff --git a/script/user_simulator.rb b/script/user_simulator.rb index 0005a6ebaec..32f6b204dd7 100644 --- a/script/user_simulator.rb +++ b/script/user_simulator.rb @@ -48,13 +48,13 @@ puts "Simulating activity for user id #{user.id}: #{user.name}" while true - # puts "Creating a random topi" + puts "Creating a random topic" - # category = Category.where(secure: false).order('random()').first - # PostCreator.create(user, raw: sentence, title: sentence[0..50].strip, category: category.name) + category = Category.where(secure: false).order('random()').first + PostCreator.create(user, raw: sentence, title: sentence[0..50].strip, category: category.name) puts "creating random reply" PostCreator.create(user, raw: sentence, topic_id: last_topics.sample) - sleep 3 + sleep 10 end