DEV: Use @cached decorator for sidebar/user/sections.js (#21556)

Achieves the same thing as the old manual caching
This commit is contained in:
David Taylor 2023-05-16 18:21:21 +01:00 committed by GitHub
parent 353c8ea51f
commit e8ee2285be
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2,20 +2,15 @@ import Component from "@glimmer/component";
import { customSections as sidebarCustomSections } from "discourse/lib/sidebar/custom-sections";
import { getOwner, setOwner } from "@ember/application";
import { inject as service } from "@ember/service";
import { cached } from "@glimmer/tracking";
export default class SidebarUserSections extends Component {
@service siteSettings;
@service currentUser;
@service site;
customSections;
constructor() {
super(...arguments);
this.customSections = this._customSections;
}
get _customSections() {
@cached
get customSections() {
return sidebarCustomSections.map((customSection) => {
const section = new customSection({ sidebar: this });
setOwner(section, getOwner(this));