FEATURE: Update HTML title tag with decrypted title.

FEATURE: Update HTML title tag with decrypted title.

diff --git a/assets/javascripts/discourse/initializers/hook-decrypt-topic.js.es6 b/assets/javascripts/discourse/initializers/hook-decrypt-topic.js.es6
index 8383cd8..a8a3785 100644
--- a/assets/javascripts/discourse/initializers/hook-decrypt-topic.js.es6
+++ b/assets/javascripts/discourse/initializers/hook-decrypt-topic.js.es6
@@ -103,6 +103,21 @@ export default {
           Ember.run.debounce(self, decryptTitles, 500);
         }
       });
+
+      api.onAppEvent("page:changed", data => {
+        if (data.currentRouteName.startsWith("topic.")) {
+          const topicId = container.lookup("controller:topic").get("model.id");
+          getTopicTitle(topicId).then(topicTitle =>
+            Discourse.set(
+              "_docTitle",
+              data.title.replace(
+                I18n.t("encrypt.encrypted_topic_title"),
+                topicTitle
+              )
+            )
+          );
+        }
+      });
     });
   }
 };

GitHub sha: 6575d69e

1 Like