From e8ee2285beb50db40a1d142476e29b58898ed934 Mon Sep 17 00:00:00 2001 From: David Taylor Date: Tue, 16 May 2023 18:21:21 +0100 Subject: [PATCH] DEV: Use `@cached` decorator for `sidebar/user/sections.js` (#21556) Achieves the same thing as the old manual caching --- .../discourse/app/components/sidebar/user/sections.js | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/app/assets/javascripts/discourse/app/components/sidebar/user/sections.js b/app/assets/javascripts/discourse/app/components/sidebar/user/sections.js index f835ad71ab1..3760431c554 100644 --- a/app/assets/javascripts/discourse/app/components/sidebar/user/sections.js +++ b/app/assets/javascripts/discourse/app/components/sidebar/user/sections.js @@ -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));