FIX: Decrypt titles from generic elements first (#118)

FIX: Decrypt titles from generic elements first (#118)

There is a list of CSS selectors that match most of the elements that contain topic titles. The generic ones can overlap with the more specific ones. It is best to decrypt the elements matched by generic ones first and then let the specific ones override them.

This commit fixes the bug that shows two secret icons in header.

diff --git a/assets/javascripts/discourse/initializers/decrypt-topics.js b/assets/javascripts/discourse/initializers/decrypt-topics.js
index 292c92c..f621840 100644
--- a/assets/javascripts/discourse/initializers/decrypt-topics.js
+++ b/assets/javascripts/discourse/initializers/decrypt-topics.js
@@ -168,6 +168,10 @@ export default {
   },
 
   decryptTitles() {
+    decryptElements("a.topic-link[data-topic-id]", "span");
+    decryptElements("a.topic-link[data-topic-id]", null, { addIcon: true });
+    decryptElements("a.raw-topic-link[data-topic-id]", null, { addIcon: true });
+
     // Title in site header
     decryptElements("h1.header-title", ".topic-link", { replaceIcon: true });
 
@@ -180,10 +184,6 @@ export default {
       ".title",
       { addIcon: true }
     );
-
-    decryptElements("a.topic-link[data-topic-id]", "span");
-    decryptElements("a.topic-link[data-topic-id]", null, { addIcon: true });
-    decryptElements("a.raw-topic-link[data-topic-id]", null, { addIcon: true });
   },
 
   decryptDocTitle(data) {

GitHub sha: 28c4354e4009d50fb92be56d2f49ec5f443277f0

This commit appears in #118 which was approved by eviltrout. It was merged by udan11.