FIX: Unescape emojis in title

FIX: Unescape emojis in title

diff --git a/assets/javascripts/discourse/initializers/hook-decrypt-topic.js.es6 b/assets/javascripts/discourse/initializers/hook-decrypt-topic.js.es6
index 103b6c1..5c16b61 100644
--- a/assets/javascripts/discourse/initializers/hook-decrypt-topic.js.es6
+++ b/assets/javascripts/discourse/initializers/hook-decrypt-topic.js.es6
@@ -1,5 +1,6 @@
 import { iconHTML } from "discourse-common/lib/icon-library";
 import { withPluginApi } from "discourse/lib/plugin-api";
+import { emojiUnescape } from "discourse/lib/text";
 import { escapeExpression } from "discourse/lib/utilities";
 import {
   ENCRYPT_ACTIVE,
@@ -31,16 +32,16 @@ function decryptElements(containerSelector, elementSelector, opts) {
     $(this).data("decrypted", true);
     getTopicTitle(topicId)
       .then(title => {
+        title = emojiUnescape(escapeExpression(title));
         const icon = iconHTML("user-secret", {
           title: "encrypt.encrypted_icon_title"
         });
 
-        // Replace glyph if exists or else add to title.
         if (opts.replaceIcon) {
           const $glyph = $(`h1 .private-message-glyph`);
           if ($glyph.length) {
             $glyph.html(icon);
-            $el.html(escapeExpression(title));
+            $el.html(title);
           }
         } else if (opts.addIcon) {
           $el.html(icon + " " + title);

GitHub sha: 0258c244

1 Like

Nice, may add a test to ensure this keep working?

Also, does this also handle titles being decrypted in the hamburger menu?

2 Likes