mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-12-02 20:07:52 -05:00
fix bugs with sync being wonky
This commit is contained in:
parent
c2e597c57c
commit
3898d90142
1 changed files with 8 additions and 8 deletions
|
@ -71,7 +71,7 @@ Discourse.TopicTrackingState = Discourse.Model.extend({
|
||||||
sync: function(list, filter){
|
sync: function(list, filter){
|
||||||
var tracker = this;
|
var tracker = this;
|
||||||
|
|
||||||
if(!list || !list.topics || !list.topics.length) { return; }
|
if(!list || !list.topics) { return; }
|
||||||
|
|
||||||
if(filter === "new" && !list.more_topics_url){
|
if(filter === "new" && !list.more_topics_url){
|
||||||
// scrub all new rows and reload from list
|
// scrub all new rows and reload from list
|
||||||
|
@ -98,9 +98,12 @@ Discourse.TopicTrackingState = Discourse.Model.extend({
|
||||||
row.topic_id = topic.id;
|
row.topic_id = topic.id;
|
||||||
if(topic.unseen) {
|
if(topic.unseen) {
|
||||||
row.last_read_post_number = null;
|
row.last_read_post_number = null;
|
||||||
} else {
|
} else if (topic.unread || topic.new_posts){
|
||||||
// subtle issue here
|
// subtle issue here
|
||||||
row.last_read_post_number = topic.last_read_post_number || topic.highest_post_number;
|
row.last_read_post_number = topic.highest_post_number - ((topic.unread||0) + (topic.new_posts||0));
|
||||||
|
} else {
|
||||||
|
delete tracker.states["t" + topic.id];
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
row.highest_post_number = topic.highest_post_number;
|
row.highest_post_number = topic.highest_post_number;
|
||||||
|
@ -108,11 +111,8 @@ Discourse.TopicTrackingState = Discourse.Model.extend({
|
||||||
row.category_name = topic.category.name;
|
row.category_name = topic.category.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (row.last_read_post_number === null || row.highest_post_number > row.last_read_post_number) {
|
tracker.states["t" + topic.id] = row;
|
||||||
tracker.states["t" + topic.id] = row;
|
|
||||||
} else {
|
|
||||||
delete tracker.states["t" + topic.id];
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
this.incrementMessageCount();
|
this.incrementMessageCount();
|
||||||
|
|
Loading…
Reference in a new issue