Plugin - Get unseen topic count per tag

In my plugin, I would like to display the unseen topic count for each tag.

I plan to implement this feature like this:

  1. Observe the topicTrackingState.messageCount property.
  2. Each time there’s a change, use the API to fetch all topics of all tags and check the unseen field.

This seems heavy. Is there another way?

(notice that, for simply getting the topic count per tag, there’s a simpler way: the tags.json API returns a list of tags with a count field)

We publish category now with the “new information” I am not against adding publishing of tags as well in core.

The tricky thing though is that this adds an extra join each time we publish info. Additionally, when we generate the initial cache we do not include tags, adding them will be expensive.

This is going to be painful.

3 Likes

Thanks @sam.

I’ve just seen that I can get the unseen topic ids from the topicTrackingState.state object (as you mentioned, I can see the category in there, but not the tags). So here is a better plan:

  1. Observe the topicTrackingState.messageCount property.
  2. Each time there’s a change, use the API to load the unseen topics and get their tags

That is SUPER expensive, would recommend against it

It is a very hard problem, I would just make the plugin publish extra messages.

2 Likes

Thanks, I will think about it.

Tell me if I’m wrong, but a consequence of this tag limitation is that, when you’re on a tag page (example here), any new topic with that tag won’t trigger the “1 new or updated topic. Click to show” message.