FIX: decrypt encrypted title in the search (#12)

FIX: decrypt encrypted title in the search (#12)

When a user is searching for personal messages, if they are encrypted, topic should be decrypted to show something useful.

Also, this is a little bit of an edge case, so to simplify, the excerpt below the title is hidden

diff --git a/assets/javascripts/discourse/initializers/hook-decrypt-topic.js.es6 b/assets/javascripts/discourse/initializers/hook-decrypt-topic.js.es6
index 63d0843..5a5ed3c 100644
--- a/assets/javascripts/discourse/initializers/hook-decrypt-topic.js.es6
+++ b/assets/javascripts/discourse/initializers/hook-decrypt-topic.js.es6
@@ -56,6 +56,12 @@ function decryptElements(containerSelector, elementSelector, opts) {
     $(this)
       .find(".edit-topic")
       .hide();
+
+    // Hide excerpt in search
+    $(this)
+      .parents(".search-link")
+      .find(".blurb")
+      .hide();
   });
 }
 
@@ -83,10 +89,13 @@ export default {
       }
     });
 
-    // Decrypt notifications when opening the user menu.
+    // Decrypt notifications when opening the user menu or searching.
     withPluginApi("0.8.31", api => {
       api.decorateWidget("header:after", helper => {
-        if (helper.widget.state.userVisible) {
+        if (
+          helper.widget.state.userVisible ||
+          helper.widget.state.searchVisible
+        ) {
           debounce(self, self.decryptTitles, 500);
         }
       });
@@ -105,6 +114,7 @@ export default {
     decryptElements("a.topic-link[data-topic-id]", { addIcon: true });
     decryptElements("a.raw-topic-link[data-topic-id]", { addIcon: true });
     decryptElements(".quick-access-panel span[data-topic-id]");
+    decryptElements(".search-result-topic span[data-topic-id]");
   },
 
   decryptDocTitle(data) {

GitHub sha: 918fa83c

This commit appears in #12 which was approved by udan11. It was merged by lis2.