mirror of
https://github.com/discourse/discourse.git
synced 2025-05-29 01:17:36 +08:00
FIX: Base topic details message on current category and tag tracking state (#12937)
The user may have changed their category or tag tracking settings since a topic was tracked/watched based on those settings in the past. In that case we need to alter the reason message we show them otherwise it is very confusing for the end user to be told they are tracking a topic because of a category, when they are no longer tracking that category. For example: "You will see a count of new replies because you are tracking this category." becomes: "You will see a count of new replies because you were tracking this category in the past." To do this, it was necessary to add tag and category tracking info to current user serializer. I improved the serializer code so it only does 3 SQL queries instead of 9 to get the tracking information for tags and categories for the current user.
This commit is contained in:
@ -207,39 +207,39 @@ class UserSerializer < UserCardSerializer
|
||||
### PRIVATE ATTRIBUTES
|
||||
###
|
||||
def muted_tags
|
||||
TagUser.lookup(object, :muted).joins(:tag).pluck('tags.name')
|
||||
tags_with_notification_level(:muted)
|
||||
end
|
||||
|
||||
def tracked_tags
|
||||
TagUser.lookup(object, :tracking).joins(:tag).pluck('tags.name')
|
||||
tags_with_notification_level(:tracked)
|
||||
end
|
||||
|
||||
def watching_first_post_tags
|
||||
TagUser.lookup(object, :watching_first_post).joins(:tag).pluck('tags.name')
|
||||
tags_with_notification_level(:watching_first_post)
|
||||
end
|
||||
|
||||
def watched_tags
|
||||
TagUser.lookup(object, :watching).joins(:tag).pluck('tags.name')
|
||||
tags_with_notification_level(:watching)
|
||||
end
|
||||
|
||||
def muted_category_ids
|
||||
CategoryUser.lookup(object, :muted).pluck(:category_id)
|
||||
categories_with_notification_level(:muted)
|
||||
end
|
||||
|
||||
def regular_category_ids
|
||||
CategoryUser.lookup(object, :regular).pluck(:category_id)
|
||||
categories_with_notification_level(:regular)
|
||||
end
|
||||
|
||||
def tracked_category_ids
|
||||
CategoryUser.lookup(object, :tracking).pluck(:category_id)
|
||||
categories_with_notification_level(:tracking)
|
||||
end
|
||||
|
||||
def watched_category_ids
|
||||
CategoryUser.lookup(object, :watching).pluck(:category_id)
|
||||
categories_with_notification_level(:watching)
|
||||
end
|
||||
|
||||
def watched_first_post_category_ids
|
||||
CategoryUser.lookup(object, :watching_first_post).pluck(:category_id)
|
||||
categories_with_notification_level(:watching_first_post)
|
||||
end
|
||||
|
||||
def muted_usernames
|
||||
|
Reference in New Issue
Block a user