Skip to content

Commit d20056a

Browse files
committed
correct watcher, live updates for unread
1 parent 6ad86aa commit d20056a

4 files changed

Lines changed: 14 additions & 8 deletions

File tree

app/assets/javascripts/discourse/controllers/list_controller.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ Discourse.ListController = Discourse.Controller.extend({
4747
draft_key: items.draft_key,
4848
draft_sequence: items.draft_sequence
4949
});
50-
if(trackingState) {
50+
if(trackingState) {
5151
trackingState.sync(items, filterMode);
5252
trackingState.trackIncoming(filterMode);
5353
}

app/assets/javascripts/discourse/models/topic_tracking_state.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ Discourse.TopicTrackingState = Discourse.Model.extend({
1717
tracker.removeTopic(data.topic_id);
1818
}
1919

20-
if (data.message_type === "new_topic" || data.message_type === "unread" || data.message_type == "read") {
21-
tracker.states["t" + data.topic_id] = data.payload;
20+
if (data.message_type === "new_topic" || data.message_type === "unread" || data.message_type === "read") {
2221
tracker.notify(data);
22+
tracker.states["t" + data.topic_id] = data.payload;
2323
}
2424

2525
tracker.incrementMessageCount();
@@ -38,6 +38,12 @@ Discourse.TopicTrackingState = Discourse.Model.extend({
3838
if ((this.filter === "latest" || this.filter === "new") && data.message_type === "new_topic" ) {
3939
this.newIncoming.push(data.topic_id);
4040
}
41+
if (this.filter === "unread" && data.message_type === "unread") {
42+
var old = this.states["t" + data.topic_id];
43+
if(!old) {
44+
this.newIncoming.push(data.topic_id);
45+
}
46+
}
4147
this.set("incomingCount", this.newIncoming.length);
4248
},
4349

app/assets/javascripts/discourse/views/list/list_topics_view.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ Discourse.ListTopicsView = Discourse.View.extend(Discourse.Scrolling, {
4949
if(topics) {
5050
return this.get('list.topics').length > 0 || this.get('topicTrackingState.hasIncoming');
5151
}
52-
}.property('list.topics','topicTrackingState.hasIncoming'),
52+
}.property('list.topics.@each','topicTrackingState.hasIncoming'),
5353

5454
loadMore: function() {
5555
var listTopicsView = this;

script/user_simulator.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,13 @@ def sentence
4848

4949

5050
while true
51-
# puts "Creating a random topi"
51+
puts "Creating a random topic"
5252

53-
# category = Category.where(secure: false).order('random()').first
54-
# PostCreator.create(user, raw: sentence, title: sentence[0..50].strip, category: category.name)
53+
category = Category.where(secure: false).order('random()').first
54+
PostCreator.create(user, raw: sentence, title: sentence[0..50].strip, category: category.name)
5555

5656
puts "creating random reply"
5757
PostCreator.create(user, raw: sentence, topic_id: last_topics.sample)
5858

59-
sleep 3
59+
sleep 10
6060
end

0 commit comments

Comments
 (0)