Skip to content

Commit

Permalink
Merge pull request #1246 from GedeonTS/make-send-btn-enabled
Browse files Browse the repository at this point in the history
[FIX] Make the send button enabled on compose page
  • Loading branch information
kroky authored Sep 30, 2024
2 parents bf3026f + 4eb2383 commit b00223a
Showing 1 changed file with 24 additions and 7 deletions.
31 changes: 24 additions & 7 deletions modules/smtp/site.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,7 @@ var save_compose_state = function(no_files, notice) {
if (!body && !subject && !to && !cc && !bcc) {
return;
}

$('.smtp_send_placeholder').prop('disabled', true);
$('.smtp_send_placeholder').addClass('disabled_input');
$('.compose_draft_id').val(0)
Hm_Ajax.request(
[{'name': 'hm_ajax_hook', 'value': 'ajax_smtp_save_draft'},
{'name': 'draft_body', 'value': body},
Expand All @@ -153,8 +151,6 @@ var save_compose_state = function(no_files, notice) {
{'name': 'draft_to', 'value': to},
{'name': 'uploaded_files', 'value': uploaded_files}],
function(res) {
$('.smtp_send_placeholder').prop('disabled', false);
$('.smtp_send_placeholder').removeClass('disabled_input');
if (res.draft_id) {
$('.compose_draft_id').val(res.draft_id);
}
Expand Down Expand Up @@ -527,13 +523,34 @@ $(function () {
modal.open();
}

function handleSendAnyway() {
function waitForValueChange(selector, targetValue) {
return new Promise((resolve) => {
const checkValue = () => {
if ($(selector).val() !== targetValue) {
resolve();
} else {
setTimeout(checkValue, 100);
}
};
checkValue();
});
}

async function handleSendAnyway() {

if ($('.compose_draft_id').val() == '0') {
Hm_Notices.show([hm_trans('Please wait, sending message...')]);
await waitForValueChange('.compose_draft_id', '0');
}



if (handleMissingAttachment()) {
document.getElementsByClassName("smtp_send")[0].click();
} else {
e.preventDefault();
}
};
}

function handleSendAnywayAndDontWarnMe() {
Hm_Utils.save_to_local_storage(dontWanValueInStorage, true);
Expand Down

0 comments on commit b00223a

Please sign in to comment.