correct watcher, live updates for unread
This commit is contained in:
parent
6ad86aa305
commit
d20056ad0e
|
@ -47,7 +47,7 @@ Discourse.ListController = Discourse.Controller.extend({
|
||||||
draft_key: items.draft_key,
|
draft_key: items.draft_key,
|
||||||
draft_sequence: items.draft_sequence
|
draft_sequence: items.draft_sequence
|
||||||
});
|
});
|
||||||
if(trackingState) {
|
if(trackingState) {
|
||||||
trackingState.sync(items, filterMode);
|
trackingState.sync(items, filterMode);
|
||||||
trackingState.trackIncoming(filterMode);
|
trackingState.trackIncoming(filterMode);
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,9 +17,9 @@ Discourse.TopicTrackingState = Discourse.Model.extend({
|
||||||
tracker.removeTopic(data.topic_id);
|
tracker.removeTopic(data.topic_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.message_type === "new_topic" || data.message_type === "unread" || data.message_type == "read") {
|
if (data.message_type === "new_topic" || data.message_type === "unread" || data.message_type === "read") {
|
||||||
tracker.states["t" + data.topic_id] = data.payload;
|
|
||||||
tracker.notify(data);
|
tracker.notify(data);
|
||||||
|
tracker.states["t" + data.topic_id] = data.payload;
|
||||||
}
|
}
|
||||||
|
|
||||||
tracker.incrementMessageCount();
|
tracker.incrementMessageCount();
|
||||||
|
@ -38,6 +38,12 @@ Discourse.TopicTrackingState = Discourse.Model.extend({
|
||||||
if ((this.filter === "latest" || this.filter === "new") && data.message_type === "new_topic" ) {
|
if ((this.filter === "latest" || this.filter === "new") && data.message_type === "new_topic" ) {
|
||||||
this.newIncoming.push(data.topic_id);
|
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);
|
this.set("incomingCount", this.newIncoming.length);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,7 @@ Discourse.ListTopicsView = Discourse.View.extend(Discourse.Scrolling, {
|
||||||
if(topics) {
|
if(topics) {
|
||||||
return this.get('list.topics').length > 0 || this.get('topicTrackingState.hasIncoming');
|
return this.get('list.topics').length > 0 || this.get('topicTrackingState.hasIncoming');
|
||||||
}
|
}
|
||||||
}.property('list.topics','topicTrackingState.hasIncoming'),
|
}.property('list.topics.@each','topicTrackingState.hasIncoming'),
|
||||||
|
|
||||||
loadMore: function() {
|
loadMore: function() {
|
||||||
var listTopicsView = this;
|
var listTopicsView = this;
|
||||||
|
|
|
@ -48,13 +48,13 @@ puts "Simulating activity for user id #{user.id}: #{user.name}"
|
||||||
|
|
||||||
|
|
||||||
while true
|
while true
|
||||||
# puts "Creating a random topi"
|
puts "Creating a random topic"
|
||||||
|
|
||||||
# category = Category.where(secure: false).order('random()').first
|
category = Category.where(secure: false).order('random()').first
|
||||||
# PostCreator.create(user, raw: sentence, title: sentence[0..50].strip, category: category.name)
|
PostCreator.create(user, raw: sentence, title: sentence[0..50].strip, category: category.name)
|
||||||
|
|
||||||
puts "creating random reply"
|
puts "creating random reply"
|
||||||
PostCreator.create(user, raw: sentence, topic_id: last_topics.sample)
|
PostCreator.create(user, raw: sentence, topic_id: last_topics.sample)
|
||||||
|
|
||||||
sleep 3
|
sleep 10
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue