From 94df97384e549eb985a10d777f397dc06cc38df7 Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Thu, 12 Feb 2026 16:17:16 -0500 Subject: [PATCH] fix: update quickreply.init so that it can be passed an options parameter, generate proper draft id for world page --- public/src/client/topic.js | 4 +++- public/src/client/world.js | 7 ++++++- public/src/modules/quickreply.js | 18 ++++-------------- 3 files changed, 13 insertions(+), 16 deletions(-) diff --git a/public/src/client/topic.js b/public/src/client/topic.js index b54185bf80..873f05df6e 100644 --- a/public/src/client/topic.js +++ b/public/src/client/topic.js @@ -425,7 +425,9 @@ define('forum/topic', [ function setupQuickReply() { if (config.enableQuickReply || (config.theme && config.theme.enableQuickReply)) { - quickreply.init(); + quickreply.init({ + route: `/topics/${ajaxify.data.tid}`, + }); } } diff --git a/public/src/client/world.js b/public/src/client/world.js index 8d7a11b927..17ef935860 100644 --- a/public/src/client/world.js +++ b/public/src/client/world.js @@ -16,7 +16,12 @@ define('forum/world', [ World.init = function () { app.enterRoom('world'); categoryTools.init($('#world-feed')); - quickreply.init(); + quickreply.init({ + route: '/topics', + body: { + cid: ajaxify.data.cid, + }, + }); sort.handleSort('categoryTopicSort', 'world'); diff --git a/public/src/modules/quickreply.js b/public/src/modules/quickreply.js index 602c1ace05..f33f73fa91 100644 --- a/public/src/modules/quickreply.js +++ b/public/src/modules/quickreply.js @@ -11,9 +11,9 @@ define('quickreply', [ _autocomplete: null, }; - QuickReply.init = function () { + QuickReply.init = function (opts) { const element = components.get('topic/quickreply/text'); - const qrDraftId = `qr:draft:tid:${ajaxify.data.tid}`; + const qrDraftId = ajaxify.data.tid ? `qr:draft:tid:${ajaxify.data.tid}` : `qr:draft:cid:${opts?.body?.cid || -1}`; const data = { element: element, strategies: [], @@ -68,18 +68,8 @@ define('quickreply', [ tid: ajaxify.data.tid, handle: undefined, content: replyMsg, + ...opts.body, }; - let replyRoute = '/topics'; - switch(ajaxify.data.template.name) { - case 'topic': - replyData.tid = ajaxify.data.tid; - replyRoute = `/topics/${ajaxify.data.tid}`; - break; - - case 'world': - replyData.cid = '-1'; - break; - } const replyLen = replyMsg.length; if (replyLen < parseInt(config.minimumPostLength, 10)) { @@ -90,7 +80,7 @@ define('quickreply', [ ready = false; element.val(''); - api.post(replyRoute, replyData, function (err, data) { + api.post(opts.route, replyData, function (err, data) { ready = true; if (err) { element.val(replyMsg);