mirror of
https://github.com/discourse/discourse.git
synced 2025-02-21 22:48:55 +08:00

What is the problem? Previously the `sections` getter was initializing duplicate `lib/sidebar/(community-)section` instances every time it was evaluated. This change in identity was causing Ember's `{{#each` helper to totally rerender every section whenever the getter was evaluated. What is the fix? This commit refactors things to lean on Ember's components for state/lifecycle management. The `{{#each` loop is done over the source data, which is guaranteed to only change identity when there is a real config change. Individual section components are initialized for each section, and are responsible for constructing and tearing down their own `lib/sidebar/(community-)section` instances. This commit also updates `lib/sidebar/(community-)section` to support service injection rather than passing service references around. Co-authored-by: David Taylor <david@taylorhq.com>