A platform for community discussion. Free, open, simple.
REFACTOR: Clean up router usage and private APIs
Robin Ward01e213c930ed
diff --git a/app/assets/javascripts/discourse/app/components/group-card-contents.js b/app/assets/javascripts/discourse/app/components/group-card-contents.jsindex 4820500e737..2bc982141bb 100644--- a/app/assets/javascripts/discourse/app/components/group-card-contents.js+++ b/app/assets/javascripts/discourse/app/components/group-card-contents.js@@ -1,4 +1,4 @@-import { alias, match, gt } from "@ember/object/computed";+import { alias, gt } from "@ember/object/computed";import Component from "@ember/component";import { setting } from "discourse/lib/computed";import discourseComputed from "discourse-common/utils/decorators";@@ -24,8 +24,6 @@ export default Component.extend(CardContentsBase, CleansUp, {showBadges: setting("enable_badges"),postStream: alias("topic.postStream"),- viewingTopic: match("currentPath", /^topic\./),-showMoreMembers: gt("moreMembersCount", 0),group: null,diff --git a/app/assets/javascripts/discourse/app/components/user-card-contents.js b/app/assets/javascripts/discourse/app/components/user-card-contents.jsindex 220cadc923d..3760b773a5e 100644--- a/app/assets/javascripts/discourse/app/components/user-card-contents.js+++ b/app/assets/javascripts/discourse/app/components/user-card-contents.js@@ -12,7 +12,6 @@ import CanCheckEmails from "discourse/mixins/can-check-emails";import CardContentsBase from "discourse/mixins/card-contents-base";import CleansUp from "discourse/mixins/cleans-up";import { prioritizeNameInUx } from "discourse/lib/settings";-import { getOwner } from "@ember/application";export default Component.extend(CardContentsBase, CanCheckEmails, CleansUp, {elementId: "user-card",@@ -201,10 +200,7 @@ export default Component.extend(CardContentsBase, CanCheckEmails, CleansUp, {composePM(user, post) {this._close();-- getOwner(this)- .lookup("router:main")- .send("composePrivateMessage", user, post);+ this.composePrivateMessage(user, post);},cancelFilter() {diff --git a/app/assets/javascripts/discourse/app/controllers/user-card.js b/app/assets/javascripts/discourse/app/controllers/user-card.jsindex a3584e9f100..a0f0cf879a2 100644--- a/app/assets/javascripts/discourse/app/controllers/user-card.js+++ b/app/assets/javascripts/discourse/app/controllers/user-card.js@@ -1,10 +1,9 @@-import { inject as service } from "@ember/service";import Controller, { inject as controller } from "@ember/controller";import DiscourseURL, { userPath, groupPath } from "discourse/lib/url";export default Controller.extend({+ application: controller(),topic: controller(),- router: service(),actions: {togglePosts(user) {diff --git a/app/assets/javascripts/discourse/app/mixins/card-contents-base.js b/app/assets/javascripts/discourse/app/mixins/card-contents-base.jsindex 54bf99e56fe..65bd103467f 100644--- a/app/assets/javascripts/discourse/app/mixins/card-contents-base.js+++ b/app/assets/javascripts/discourse/app/mixins/card-contents-base.js@@ -5,14 +5,17 @@ import afterTransition from "discourse/lib/after-transition";import DiscourseURL from "discourse/lib/url";import Mixin from "@ember/object/mixin";import { escapeExpression } from "discourse/lib/utilities";+import { inject as service } from "@ember/service";export default Mixin.create({+ router: service(),+elementId: null, //click detection added for data-{elementId}triggeringLinkClass: null, //the <a> classname where this card should appear_showCallback: null, //username, $target - load up data for when show is called, should call this._positionCard($target) when it's done.postStream: alias("topic.postStream"),- viewingTopic: match("currentPath", /^topic\./),+ viewingTopic: match("router.currentRouteName", /^topic\./),visible: false,username: null,diff --git a/app/assets/javascripts/discourse/app/templates/user-card.hbs b/app/assets/javascripts/discourse/app/templates/user-card.hbsindex d06bb8ae001..5475c398178 100644--- a/app/assets/javascripts/discourse/app/templates/user-card.hbs+++ b/app/assets/javascripts/discourse/app/templates/user-card.hbs@@ -3,14 +3,13 @@{{/if}}{{user-card-contents- currentPath=router._router.currentPathtopic=topic.modelshowUser=(action "showUser")togglePosts=(action "togglePosts")+ composePrivateMessage=(route-action "composePrivateMessage")createNewMessageViaParams=(route-action "createNewMessageViaParams")}}{{group-card-contents- currentPath=router._router.currentPathtopic=topic.modelshowUser=(action "showUser")showGroup=(action "showGroup")