Skip to content

Commit

Permalink
Fix selenium tests
Browse files Browse the repository at this point in the history
  • Loading branch information
josaphatim committed Jan 23, 2025
1 parent a134b65 commit 96ce315
Showing 1 changed file with 18 additions and 16 deletions.
34 changes: 18 additions & 16 deletions modules/smtp/site.js
Original file line number Diff line number Diff line change
Expand Up @@ -391,21 +391,23 @@ function smtpSettingsPageHandler() {
}

$(function() {
var scheduled_msg_count = 0;
var sendScheduledMessages = function() {
Hm_Ajax.request(
[{'name': 'hm_ajax_hook', 'value': 'ajax_send_scheduled_messages'}],
function(res) {
scheduled_msg_count = res.scheduled_msg_count;
},
);
}

sendScheduledMessages();
setInterval(sendScheduledMessages, 60000);
window.onbeforeunload = (e) => {
if (scheduled_msg_count > 0 && e.currentTarget.location.hostname !== document.location.hostname) {
return sprintf(hm_trans("You have %d scheduled messages that won\'t be executed if you quit"), scheduled_msg_count);
if (hm_is_logged()) {
var scheduled_msg_count = 0;
var sendScheduledMessages = function() {
Hm_Ajax.request(
[{'name': 'hm_ajax_hook', 'value': 'ajax_send_scheduled_messages'}],
function(res) {
scheduled_msg_count = res.scheduled_msg_count;
},
);
}
};

sendScheduledMessages();
setInterval(sendScheduledMessages, 60000);
window.onbeforeunload = (e) => {
if (scheduled_msg_count > 0 && e.currentTarget.location.hostname !== document.location.hostname) {
return sprintf(hm_trans("You have %d scheduled messages that won\'t be executed if you quit"), scheduled_msg_count);
}
};
}
});

0 comments on commit 96ce315

Please sign in to comment.