FIX: ensures reply template works within discourse-docs posts

FIX: ensures reply template works within discourse-docs posts

diff --git a/javascripts/discourse/initializers/init-discourse-reply-template-component.js.es6 b/javascripts/discourse/initializers/init-discourse-reply-template-component.js.es6
index 41f3e20..987a11c 100644
--- a/javascripts/discourse/initializers/init-discourse-reply-template-component.js.es6
+++ b/javascripts/discourse/initializers/init-discourse-reply-template-component.js.es6
@@ -90,6 +90,14 @@ function _reply(dataset, post, controllerOptions) {
   });
 }
 
+function _buildDraftKey(topicId, action) {
+  if (!action || action === "reply") {
+    return `topic_${topicId}`;
+  }
+
+  return "new_topic";
+}
+
 function openComposerWithTemplateAndAction(controller, post, wrap) {
   const currentUser = getOwner(this).lookup("current-user:main");
   if (!currentUser) {
@@ -169,8 +177,10 @@ function openComposerWithTemplateAndAction(controller, post, wrap) {
 
       let controllerOptions = {
         topicBody,
-        draftKey: controller.topicModel.draft_key,
-        draftSequence: controller.topicModel.draftSequence,
+        draftKey:
+          controller.topicModel?.draft_key ||
+          _buildDraftKey(post.topic_id, dataset.action),
+        draftSequence: controller.topicModel?.draftSequence,
         skipDraftCheck: true,
         categoryId: dataset.categoryId || null
       };

GitHub sha: 9cb18128c5376adde3d0c09b6acbef718589fd75