fix: update quickreply.init so that it can be passed an options parameter, generate proper draft id for world page

This commit is contained in:
Julian Lam
2026-02-12 16:17:16 -05:00
parent 4bf0f61ea3
commit 94df97384e
3 changed files with 13 additions and 16 deletions

View File

@@ -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}`,
});
}
}

View File

@@ -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');

View File

@@ -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);