REFACTOR: Clean up router usage and private APIs

REFACTOR: Clean up router usage and private APIs

diff --git a/app/assets/javascripts/discourse/app/components/group-card-contents.js b/app/assets/javascripts/discourse/app/components/group-card-contents.js
index 4820500..2bc9821 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.js
index 220cadc..3760b77 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.js
index a3584e9..a0f0cf8 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.js
index 54bf99e..65bd103 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.hbs
index d06bb8a..5475c39 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.currentPath
   topic=topic.model
   showUser=(action "showUser")
   togglePosts=(action "togglePosts")
+  composePrivateMessage=(route-action "composePrivateMessage")
   createNewMessageViaParams=(route-action "createNewMessageViaParams")}}
 
 {{group-card-contents
-  currentPath=router._router.currentPath
   topic=topic.model
   showUser=(action "showUser")
   showGroup=(action "showGroup")

GitHub sha: 01e213c9

This commit appears in #10443 which was merged by eviltrout.