mirror of
https://github.com/discourse/discourse.git
synced 2025-02-24 03:24:10 +08:00

In eb12daa7f8793092bf4fe0c180a04fa3ea2d13e1 when adding community section support for anonymous users, we changed the `sectionLinks` property into a getter method. This meant that if the getter method was called again after the community section has been rendered, we would end up reintializing the section links classes. As part of the initialisation, some section links would setup a TopicTrackingState onStateChange listener. However, the listener is only removed when the entire community section is removed which resulted in us leaking the onStateChange listeners. This commit reverts the `sectionLinks` from being defined as a getter method into a property which is only set once when the community section is being constructor. Also, we changed it such that the community section will register the listener instead of each section link since it makes cleaning up much easier to reason about. No tests have been added for this commit because the original bug is not possible after this change and we already have an existing tests ensuring that TopicTrackingState change listeners are cleaned up when the community section is destroyed. Internal ref: /t/73224