Skip to content

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

FIX: render emojis in topic titles on reactions pages

zogstrip09dd97876390
diff --git a/plugins/discourse-reactions/assets/javascripts/discourse/models/discourse-reactions-custom-reaction.js b/plugins/discourse-reactions/assets/javascripts/discourse/models/discourse-reactions-custom-reaction.js
index 8db32fae611..4306fdb7ded 100644
--- a/plugins/discourse-reactions/assets/javascripts/discourse/models/discourse-reactions-custom-reaction.js
+++ b/plugins/discourse-reactions/assets/javascripts/discourse/models/discourse-reactions-custom-reaction.js
@@ -1,5 +1,7 @@
import EmberObject from "@ember/object";
import { ajax } from "discourse/lib/ajax";
+import { emojiUnescape } from "discourse/lib/text";
+import { escapeExpression } from "discourse/lib/utilities";
import Category from "discourse/models/category";
import Post from "discourse/models/post";
import RestModel from "discourse/models/rest";
@@ -22,6 +24,7 @@ export default class CustomReaction extends RestModel {
}
static flattenForPostList(reaction) {
+ const title = reaction.topic.title;
return {
// Original reaction data
...reaction,
@@ -40,7 +43,8 @@ export default class CustomReaction extends RestModel {
topic_id: reaction.post.topic_id,
post_type: reaction.post.post_type,
url: reaction.post.url,
- title: reaction.topic.title,
+ title,
+ titleHtml: title && emojiUnescape(escapeExpression(title)),
category: reaction.category,
created_at: reaction.created_at,
};
diff --git a/plugins/discourse-reactions/assets/javascripts/discourse/templates/user-activity/reactions.gjs b/plugins/discourse-reactions/assets/javascripts/discourse/templates/user-activity/reactions.gjs
index 00188d85c6c..fd4e410e2f0 100644
--- a/plugins/discourse-reactions/assets/javascripts/discourse/templates/user-activity/reactions.gjs
+++ b/plugins/discourse-reactions/assets/javascripts/discourse/templates/user-activity/reactions.gjs
@@ -8,6 +8,7 @@ export default <template>
@fetchMorePosts={{@controller.loadMore}}
@emptyText={{i18n "notifications.empty"}}
@additionalItemClasses="user-stream-item"
+ @titlePath="titleHtml"
@showUserInfo={{false}}
class="user-stream"
>
diff --git a/plugins/discourse-reactions/test/javascripts/acceptance/discourse-reactions-received-test.js b/plugins/discourse-reactions/test/javascripts/acceptance/discourse-reactions-received-test.js
index 1e6d2af0c3e..8ec126b14d8 100644
--- a/plugins/discourse-reactions/test/javascripts/acceptance/discourse-reactions-received-test.js
+++ b/plugins/discourse-reactions/test/javascripts/acceptance/discourse-reactions-received-test.js
@@ -26,9 +26,9 @@ acceptance("Discourse Reactions - Reactions Received Page", function (needs) {
id: 123,
created_at: "2024-01-01T00:00:00.000Z",
topic_id: 1,
- topic_title: "Test Topic",
+ topic_title: "Test Topic :open_book:",
topic_slug: "test-topic",
- topic_html_title: "Test Topic",
+ topic_html_title: "Test Topic :open_book:",
post_number: 1,
posts_count: 5,
post_type: 1,
@@ -52,8 +52,8 @@ acceptance("Discourse Reactions - Reactions Received Page", function (needs) {
},
topic: {
id: 1,
- title: "Test Topic",
- fancy_title: "Test Topic",
+ title: "Test Topic :open_book:",
+ fancy_title: "Test Topic :open_book:",
slug: "test-topic",
posts_count: 5,
},
@@ -98,4 +98,19 @@ acceptance("Discourse Reactions - Reactions Received Page", function (needs) {
"mention does not contain spaces (which would indicate a full name)"
);
});
+
+ test("emojis in topic titles are rendered as images", async function (assert) {
+ await visit("/u/eviltrout/notifications/reactions-received");
+
+ assert
+ .dom(".post-list-item .stream-topic-title .title img.emoji")
+ .exists("emoji is rendered as an image in topic title");
+
+ assert
+ .dom(".post-list-item .stream-topic-title .title")
+ .doesNotIncludeText(
+ ":open_book:",
+ "emoji code is not displayed as plain text"
+ );
+ });
});