correct suggested list trigger to perform all work AFTER it is debounced, avoids incorrect new/unread items

This commit is contained in:
Sam 2013-06-17 12:00:06 +10:00
parent e603c85fa0
commit fe979b7299
1 changed files with 10 additions and 11 deletions

View File

@ -127,16 +127,9 @@ Discourse.TopicView = Discourse.View.extend(Discourse.Scrolling, {
this.updatePosition(true);
},
debounceLoadSuggested: Discourse.debounce(function(lookup){
var suggested = this.get('topic.suggested_topics');
debounceLoadSuggested: Discourse.debounce(function(){
if (this.get('isDestroyed') || this.get('isDestroying')) { return; }
Discourse.TopicList.loadTopics(lookup, "").then(function(topics){
suggested.clear();
suggested.pushObjects(topics);
});
}, 1000),
hasNewSuggested: function(){
var incoming = this.get('topicTrackingState.newIncoming');
var suggested = this.get('topic.suggested_topics');
var topicId = this.get('topic.id');
@ -154,9 +147,15 @@ Discourse.TopicView = Discourse.View.extend(Discourse.Scrolling, {
.first(5)
.value();
this.debounceLoadSuggested(lookup);
Discourse.TopicList.loadTopics(lookup, "").then(function(topics){
suggested.clear();
suggested.pushObjects(topics);
});
}
}, 1000),
hasNewSuggested: function(){
this.debounceLoadSuggested();
}.observes('topicTrackingState.incomingCount'),
// Triggered whenever any posts are rendered, debounced to save over calling