From 868778b07959986339bb72ac0a7b4e1b86b3c4ec Mon Sep 17 00:00:00 2001 From: EvilFear <52994635+Hakirus@users.noreply.github.com> Date: Wed, 6 Sep 2023 22:27:03 -0400 Subject: [PATCH] Update index.js Quick Reply Mod --- .../scripts/extensions/quick-reply/index.js | 36 +++++++++++++++++-- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/public/scripts/extensions/quick-reply/index.js b/public/scripts/extensions/quick-reply/index.js index 44360bc34..e06891522 100644 --- a/public/scripts/extensions/quick-reply/index.js +++ b/public/scripts/extensions/quick-reply/index.js @@ -99,7 +99,14 @@ async function onQuickReplyEnabledInput() { saveSettingsDebounced(); } +// New function to handle input on quickActionEnabled +async function onQuickActionEnabledInput() { + extension_settings.quickReply.quickActionEnabled = $(this).prop('checked'); + saveSettingsDebounced(); +} + async function sendQuickReply(index) { + const existingText = $("#send_textarea").val(); const prompt = extension_settings.quickReply.quickReplySlots[index]?.mes || ''; if (!prompt) { @@ -107,8 +114,25 @@ async function sendQuickReply(index) { return; } - $("#send_textarea").val(prompt); - $("#send_but").trigger('click'); + let newText; + + if (existingText) { + // If existing text, add space after prompt + newText = existingText + ' ' + prompt + ' '; + } else { + // If no existing text, add prompt only + newText = prompt + ' '; + } + + $("#send_textarea").val(newText); + + // Set the focus back to the textarea + $("#send_textarea").focus(); + + // Only trigger send button if quickActionEnabled is not checked + if (!$("#quickActionEnabled").prop('checked')) { + $("#send_but").trigger('click'); + } } function addQuickReplyBar() { @@ -309,6 +333,10 @@ jQuery(async () => { Enable Quick Replies +