FIX: Inconsistency between unread counter and unread filter

This commit is contained in:
Robin Ward 2014-08-18 16:15:26 -04:00
parent c5d6f6a034
commit f1486c7728
3 changed files with 12 additions and 2 deletions

View file

@ -157,6 +157,8 @@ Discourse.TopicTrackingState = Discourse.Model.extend({
list.topics.forEach(function(topic){
var row = tracker.states["t" + topic.id] || {};
row.topic_id = topic.id;
row.notification_level = topic.notification_level;
if (topic.unseen) {
row.last_read_post_number = null;

View file

@ -18,7 +18,8 @@ class ListableTopicSerializer < BasicTopicSerializer
:excerpt,
:visible,
:closed,
:archived
:archived,
:notification_level
has_one :last_poster, serializer: BasicUserSerializer, embed: :objects
def include_last_poster?
@ -40,6 +41,13 @@ class ListableTopicSerializer < BasicTopicSerializer
!seen
end
def notification_level
object.user_data.notification_level
end
def include_notification_level?
object.user_data.present?
end
def last_read_post_number
return nil unless object.user_data
object.user_data.last_read_post_number

View file

@ -147,7 +147,7 @@ class TopicQuery
end
def self.unread_filter(list)
list.where("tu.last_read_post_number < topics.highest_post_number")
list.where("tu.seen_post_count < topics.highest_post_number")
.where("COALESCE(tu.notification_level, :regular) >= :tracking", regular: TopicUser.notification_levels[:regular], tracking: TopicUser.notification_levels[:tracking])
end