discourse/app
Alan Guo Xiang Tan 18c542dc02
PERF: Avoid triggering TopicTrackingState change callbacks unnecessarily (#21425)
What is the problem?

The TopicTrackingState is a service on the client side that is used to store
state of topics which is new or has unread posts for a given user. The state
is updated via various means and the one in concern here is whenever we load
a new topic list from the server. When a topic list is loaded from the server,
we sync this new topic list with the states in TopicTrackingState. There is also
a hard limit on the number of states that is stored by TopicTrackingState for
performance reasons and the limit is currently set to 4000. It was noticed that
once this limit has been reached, syncing a topic list with TopicTrackingState can
result in the registered state change callbacks to be called unnecessarily. This
is because during `TopicTrackingState#sync` we call `TopicTrackingState#removeTopic`
if the topic in question is neither new or unread to a user. However, `TopicTrackingState#removeTopic`
would call `TopicTrackingState#_afterStateChange` even if nothing was removed.

What is the fix?

This commit fixes the problem by checking that `TopicTrackingState#_afterStateChange` is only
called in `TopicTrackingState#removeTopic` when a topic is actually removed.
2023-05-08 13:26:28 +10:00
..
assets PERF: Avoid triggering TopicTrackingState change callbacks unnecessarily (#21425) 2023-05-08 13:26:28 +10:00
controllers DEV: move sidebar community section to database (#21166) 2023-05-04 12:14:09 +10:00
helpers UX: Improve login required page (#20847) 2023-03-28 07:09:44 -05:00
jobs FEATURE: Add new notification for admin problems (#21287) 2023-05-03 19:35:22 +03:00
mailers DEV: Replace #pluck_first freedom patch with AR #pick in core (#19893) 2023-02-13 12:39:45 +08:00
models DEV: In test, if flush is called and there is no thread, flush inline (#21426) 2023-05-08 13:25:00 +10:00
serializers DEV: move sidebar community section to database (#21166) 2023-05-04 12:14:09 +10:00
services PERF: Don't serialize value for theme_fields unnecessarily (#21201) 2023-04-24 09:30:51 -05:00
views UX: Include subcategories in crawler view (#21227) 2023-04-25 10:51:45 -04:00