Skip to content

A platform for community discussion. Free, open, simple.

FIX: use correct attribute method to get post id from dataset. (#14845)

Vinoth Kannand549022afbc1
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 745375d22ec..3c64c2fc839 100644
--- a/app/assets/javascripts/discourse/app/components/user-card-contents.js
+++ b/app/assets/javascripts/discourse/app/components/user-card-contents.js
@@ -206,9 +206,9 @@ export default Component.extend(CardContentsBase, CanCheckEmails, CleansUp, {
this._close();
},
- composePM(user) {
+ composePM(user, post) {
this._close();
- this.composePrivateMessage(user, this.topic);
+ this.composePrivateMessage(user, post);
},
cancelFilter() {
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 813995fe8a7..e5f0bf139fc 100644
--- a/app/assets/javascripts/discourse/app/mixins/card-contents-base.js
+++ b/app/assets/javascripts/discourse/app/mixins/card-contents-base.js
@@ -63,7 +63,7 @@ export default Mixin.create({
}
const closestArticle = target.closest("article");
- const postId = closestArticle ? closestArticle.dataset["post-id"] : null;
+ const postId = closestArticle ? closestArticle.dataset.postId : null;
const wasVisible = this.visible;
const previousTarget = this.cardTarget;
diff --git a/app/assets/javascripts/discourse/app/routes/application.js b/app/assets/javascripts/discourse/app/routes/application.js
index b957f9be4de..9ffcb3987fa 100644
--- a/app/assets/javascripts/discourse/app/routes/application.js
+++ b/app/assets/javascripts/discourse/app/routes/application.js
@@ -70,14 +70,14 @@ const ApplicationRoute = DiscourseRoute.extend(OpenComposer, {
});
},
- composePrivateMessage(user, topic) {
+ composePrivateMessage(user, post) {
const recipients = user ? user.get("username") : "";
- const reply = topic
- ? `${window.location.protocol}//${window.location.host}${topic.url}`
+ const reply = post
+ ? `${window.location.protocol}//${window.location.host}${post.url}`
: null;
- const title = topic
+ const title = post
? I18n.t("composer.reference_topic_title", {
- title: topic.title,
+ title: post.topic.title,
})
: null;
diff --git a/app/assets/javascripts/discourse/app/templates/components/user-card-contents.hbs b/app/assets/javascripts/discourse/app/templates/components/user-card-contents.hbs
index b919dda04d6..c08cfcd6a4e 100644
--- a/app/assets/javascripts/discourse/app/templates/components/user-card-contents.hbs
+++ b/app/assets/javascripts/discourse/app/templates/components/user-card-contents.hbs
@@ -68,7 +68,7 @@
<li class="compose-pm">
{{d-button
class="btn-primary"
- action=(action "composePM" this.user)
+ action=(action "composePM" this.user this.post)
icon="envelope"
label="user.private_message"}}
</li>