mirror of
https://github.com/discourse/discourse.git
synced 2025-01-18 20:52:46 +08:00
DEV: Use @cached
decorator for sidebar/user/sections.js
(#21556)
Achieves the same thing as the old manual caching
This commit is contained in:
parent
353c8ea51f
commit
e8ee2285be
|
@ -2,20 +2,15 @@ import Component from "@glimmer/component";
|
||||||
import { customSections as sidebarCustomSections } from "discourse/lib/sidebar/custom-sections";
|
import { customSections as sidebarCustomSections } from "discourse/lib/sidebar/custom-sections";
|
||||||
import { getOwner, setOwner } from "@ember/application";
|
import { getOwner, setOwner } from "@ember/application";
|
||||||
import { inject as service } from "@ember/service";
|
import { inject as service } from "@ember/service";
|
||||||
|
import { cached } from "@glimmer/tracking";
|
||||||
|
|
||||||
export default class SidebarUserSections extends Component {
|
export default class SidebarUserSections extends Component {
|
||||||
@service siteSettings;
|
@service siteSettings;
|
||||||
@service currentUser;
|
@service currentUser;
|
||||||
@service site;
|
@service site;
|
||||||
|
|
||||||
customSections;
|
@cached
|
||||||
|
get customSections() {
|
||||||
constructor() {
|
|
||||||
super(...arguments);
|
|
||||||
this.customSections = this._customSections;
|
|
||||||
}
|
|
||||||
|
|
||||||
get _customSections() {
|
|
||||||
return sidebarCustomSections.map((customSection) => {
|
return sidebarCustomSections.map((customSection) => {
|
||||||
const section = new customSection({ sidebar: this });
|
const section = new customSection({ sidebar: this });
|
||||||
setOwner(section, getOwner(this));
|
setOwner(section, getOwner(this));
|
||||||
|
|
Loading…
Reference in New Issue
Block a user