Skip to content

Commit

Permalink
fixed lint
Browse files Browse the repository at this point in the history
  • Loading branch information
luciafang committed Sep 29, 2024
1 parent ca84351 commit 1c97fd0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 61 deletions.
Binary file modified dump.rdb
Binary file not shown.
70 changes: 9 additions & 61 deletions public/src/modules/quickreply.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ define('quickreply', [
alerts, uploadHelpers, mousetrap, storage, hooks
) {
const QuickReply = {};
let ready = true;
let qrDraftId = null;
const qrDraftId = null;

QuickReply.init = function () {
const element = components.get('topic/quickreply/text');
Expand Down Expand Up @@ -52,23 +51,20 @@ define('quickreply', [
},
});

// Existing Quick Reply button event handler
components.get('topic/quickreply/button').on('click', function (e) {
e.preventDefault();
postReply(false); // Not anonymous
postReply(false);
});
// Create and append the new Reply Anonymously button after the quick reply button is available

// append the new Reply Anonymously button
const quickReplyContainer = $('[component="topic/quickreply/container"]');
if (quickReplyContainer.length) {
const anonymousButton = $('<button type="button" class="btn btn-secondary reply-anonymously">Reply Anonymously</button>');
quickReplyContainer.append(anonymousButton);

// Attach the click event handler to the new Reply Anonymously button
anonymousButton.on('click', function (e) {
e.preventDefault();
console.log("Anonymous reply button clicked!");
postReply(true); // Anonymous reply
console.log('Anonymous reply button clicked!');
postReply(true);
});
}

Expand Down Expand Up @@ -99,44 +95,24 @@ define('quickreply', [
});
};


// const replyMsg = components.get('topic/quickreply/text').val();
// const replyData = {
// tid: ajaxify.data.tid,
// handle: undefined,
// content: replyMsg,
// anonymous: anonymous, // Add the anonymous flag
// };
function postReply(anonymous) { // Updated to include anonymous parameter
function postReply(anonymous) {
const element = components.get('topic/quickreply/text');
const replyMsg = element.val();
const replyData = {
tid: ajaxify.data.tid,
handle: undefined,
content: replyMsg,
anonymous: anonymous, // anonymous
anonymous: anonymous,
};
console.log("Reply Data being sent:", replyData);

// Check if replyMsg is null or undefined
const replyLen = replyMsg.length;
console.log("Reply message length:", replyLen); // Check the length

console.log("Minimum post length:", parseInt(config.minimumPostLength, 10));
console.log("Maximum post length:", parseInt(config.maximumPostLength, 10));

if (replyLen < parseInt(config.minimumPostLength, 10)) {
return alerts.error('[[error:content-too-short, ' + config.minimumPostLength + ']]');
} else if (replyLen > parseInt(config.maximumPostLength, 10)) {
return alerts.error('[[error:content-too-long, ' + config.maximumPostLength + ']]');
}
console.log("Content length is within valid range.");

ready = false;
console.log("Triggering api.post with data:", replyData);

api.post(`/topics/${ajaxify.data.tid}`, replyData, function (err, data) {
ready = true;
if (err) {
return alerts.error(err);
}
Expand All @@ -158,35 +134,7 @@ define('quickreply', [
autocomplete._active.core_qr.hide();
hooks.fire('action:quickreply.success', { data });
});
}


// const draft = storage.getItem(qrDraftId);
// if (draft) {
// element.val(draft);
// }

// element.on('keyup', utils.debounce(function () {
// const text = element.val();
// if (text) {
// storage.setItem(qrDraftId, text);
// } else {
// storage.removeItem(qrDraftId);
// }
// }, 1000));

// components.get('topic/quickreply/expand').on('click', (e) => {
// e.preventDefault();
// storage.removeItem(qrDraftId);
// const textEl = components.get('topic/quickreply/text');
// composer.newReply({
// tid: ajaxify.data.tid,
// title: ajaxify.data.titleRaw,
// body: textEl.val(),
// });
// textEl.val('');
// });
// };
}

function destroyAutoComplete() {
if (autocomplete._active.core_qr) {
Expand Down

0 comments on commit 1c97fd0

Please sign in to comment.