discourse/app/assets/javascripts/discourse
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
..
app PERF: Avoid triggering TopicTrackingState change callbacks unnecessarily (#21425) 2023-05-08 13:26:28 +10:00
config Revert "DEV: Replace Ember implicit injections with base class extensions (#21258)" (#21397) 2023-05-05 09:26:07 +10:00
lib Revert "DEV: Merge package.json files (#21172)" (#21182) 2023-04-20 14:57:40 +02:00
public/assets/scripts DEV: Extract global compat code into module (#20901) 2023-04-06 10:09:12 +01:00
scripts Drop support for iOS < 15.7 (#19847) 2023-01-16 17:28:59 +00:00
tests PERF: Avoid triggering TopicTrackingState change callbacks unnecessarily (#21425) 2023-05-08 13:26:28 +10:00
.ember-cli DEV: Update ember-cli to 4.12.0 (#21074) 2023-04-19 12:58:29 +02:00
.npmrc
ember-cli-build.js DEV: Update ember-cli to 4.12.0 (#21074) 2023-04-19 12:58:29 +02:00
jsconfig.json DEV: Add discourse/tests to jsconfig (#19031) 2022-11-15 11:33:56 +00:00
package.json Build(deps): Bump ember-source in /app/assets/javascripts 2023-05-05 12:56:24 +01:00
testem.js DEV: Move shouldLoadPluginTestJs() (#19045) 2022-11-16 11:07:58 +01:00