mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-02-18 20:47:33 +01:00
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:
@@ -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}`,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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');
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user