FIX: Base topic details message on current category and tag tracking state (PR #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.

GitHub

Makes this code consistent with set_default_tags_preferences below

I’m trying to move us away from User.current() since it’s a singleton. Rather than a computed property is there any way this could be a function that’s called somewhere like a controller or component where this.currentUser is present?

This seems good, but it’s hard to eyeball any performance issues or n+1 queries. We should probably not merge this until after the release unless we are very sure about this.

@eviltrout This only adds 1 query to the current user serializer on page load to preload the current user data, and reduces the queries a lot when calling the /u/:username route, so I think it is safe to merge with no N1 or performance impacts.

master - loading home route

57 SQL total - 14 SQL in current user serializer

this branch - loading home route

58 SQL total - 15 SQL in current user serializer

master - loading /u/:username route

82 SQL total - 19 SQL in user serializer

this branch - loading /u/:username route

76 SQL total - 12 SQL in user serializer

Yes I think it can be passed in, will change this.

@eviltrout I moved this whole notificationReasonText method into the topic-notification-button component and moved the tests to that component as well :slight_smile:

Much nicer, thank you.