mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-03-03 19:11:22 +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() {
|
function setupQuickReply() {
|
||||||
if (config.enableQuickReply || (config.theme && config.theme.enableQuickReply)) {
|
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 () {
|
World.init = function () {
|
||||||
app.enterRoom('world');
|
app.enterRoom('world');
|
||||||
categoryTools.init($('#world-feed'));
|
categoryTools.init($('#world-feed'));
|
||||||
quickreply.init();
|
quickreply.init({
|
||||||
|
route: '/topics',
|
||||||
|
body: {
|
||||||
|
cid: ajaxify.data.cid,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
sort.handleSort('categoryTopicSort', 'world');
|
sort.handleSort('categoryTopicSort', 'world');
|
||||||
|
|
||||||
|
|||||||
@@ -11,9 +11,9 @@ define('quickreply', [
|
|||||||
_autocomplete: null,
|
_autocomplete: null,
|
||||||
};
|
};
|
||||||
|
|
||||||
QuickReply.init = function () {
|
QuickReply.init = function (opts) {
|
||||||
const element = components.get('topic/quickreply/text');
|
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 = {
|
const data = {
|
||||||
element: element,
|
element: element,
|
||||||
strategies: [],
|
strategies: [],
|
||||||
@@ -68,18 +68,8 @@ define('quickreply', [
|
|||||||
tid: ajaxify.data.tid,
|
tid: ajaxify.data.tid,
|
||||||
handle: undefined,
|
handle: undefined,
|
||||||
content: replyMsg,
|
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;
|
const replyLen = replyMsg.length;
|
||||||
if (replyLen < parseInt(config.minimumPostLength, 10)) {
|
if (replyLen < parseInt(config.minimumPostLength, 10)) {
|
||||||
@@ -90,7 +80,7 @@ define('quickreply', [
|
|||||||
|
|
||||||
ready = false;
|
ready = false;
|
||||||
element.val('');
|
element.val('');
|
||||||
api.post(replyRoute, replyData, function (err, data) {
|
api.post(opts.route, replyData, function (err, data) {
|
||||||
ready = true;
|
ready = true;
|
||||||
if (err) {
|
if (err) {
|
||||||
element.val(replyMsg);
|
element.val(replyMsg);
|
||||||
|
|||||||
Reference in New Issue
Block a user