mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
DEV: pass owner instead of services (#31090)
Passing the owner allows section class to access services without having to pass each service instance one by one.
This commit is contained in:
@@ -1,22 +1,18 @@
|
||||
import { setOwner } from "@ember/owner";
|
||||
import { service } from "@ember/service";
|
||||
|
||||
/**
|
||||
* Base class representing a sidebar communtiy section link interface.
|
||||
*/
|
||||
export default class BaseCommunitySectionLink {
|
||||
constructor({
|
||||
topicTrackingState,
|
||||
currentUser,
|
||||
appEvents,
|
||||
router,
|
||||
siteSettings,
|
||||
inMoreDrawer,
|
||||
overridenName,
|
||||
overridenIcon,
|
||||
} = {}) {
|
||||
this.router = router;
|
||||
this.topicTrackingState = topicTrackingState;
|
||||
this.currentUser = currentUser;
|
||||
this.appEvents = appEvents;
|
||||
this.siteSettings = siteSettings;
|
||||
@service currentUser;
|
||||
@service appEvents;
|
||||
@service router;
|
||||
@service siteSettings;
|
||||
@service topicTrackingState;
|
||||
|
||||
constructor(owner, { inMoreDrawer, overridenName, overridenIcon } = {}) {
|
||||
setOwner(this, owner);
|
||||
this.inMoreDrawer = inMoreDrawer;
|
||||
this.overridenName = overridenName;
|
||||
this.overridenIcon = overridenIcon;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { tracked } from "@glimmer/tracking";
|
||||
import { setOwner } from "@ember/owner";
|
||||
import { getOwner, setOwner } from "@ember/owner";
|
||||
import { service } from "@ember/service";
|
||||
import AboutSectionLink from "discourse/lib/sidebar/common/community-section/about-section-link";
|
||||
import BadgesSectionLink from "discourse/lib/sidebar/common/community-section/badges-section-link";
|
||||
@@ -130,12 +130,7 @@ export default class CommunitySection {
|
||||
if (this.router.isDestroying) {
|
||||
return;
|
||||
}
|
||||
return new sectionLinkClass({
|
||||
topicTrackingState: this.topicTrackingState,
|
||||
currentUser: this.currentUser,
|
||||
appEvents: this.appEvents,
|
||||
router: this.router,
|
||||
siteSettings: this.siteSettings,
|
||||
return new sectionLinkClass(getOwner(this), {
|
||||
inMoreDrawer,
|
||||
overridenName,
|
||||
overridenIcon,
|
||||
|
||||
Reference in New Issue
Block a user