يمكنك إلقاء نظرة على كيفية دمج المكون الإضافي للدردشة مع الشريط الجانبي:
في هذه الحالة، يتم الاحتفاظ بحالة الروابط في كائن الخدمة وكلما تغيرت الحالة، يتم تحديث الشريط الجانبي:
قد يكون الحل المحتمل هو الاشتراك في حدث تغيير الصفحة وتحديث الروابط. قد يبدو الكود الزائف كالتالي:
import { tracked } from "@glimmer/tracking";
api.addSidebarSection(
(BaseCustomSidebarSection, BaseCustomSidebarSectionLink) => {
const TestSectionLink = class extends BaseCustomSidebarSectionLink {
// define your custom link properties here
};
const SidebarTestSection = class extends BaseCustomSidebarSection {
@tracked links = [];
constructor() {
super(...arguments);
this.#updateLinks();
this.onAppEvent("page:changed", () => this.#updateLinks());
}
get newLinksArray() {
// list of links based on current URL
}
#updateLinks() {
this.links = this.newLinksArray.map(
(link) =>
new TestSectionLink({
link,
})
);
}
get sectionLinks() {
return this.links;
}
};
return SidebarTestSection;
}
);