Skip to content

Commit

Permalink
The browser title updates, message controls work, & unecessary unread…
Browse files Browse the repository at this point in the history
… requests are stopped
  • Loading branch information
mercihabam committed Oct 19, 2024
1 parent 28b39ac commit c39f4f0
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 7 deletions.
2 changes: 2 additions & 0 deletions modules/core/navigation/navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ async function navigate(url) {

const html = await response.text();
const main = html.match(/<main[^>]*>((.|[\n\r])*)<\/main>/i)[0];
const title = html.match(/<title[^>]*>((.|[\n\r])*)<\/title>/i)[0];
$('main').replaceWith(main);
document.title = title.replace(/<[^>]*>/g, '');

window.location.next = url;

Expand Down
12 changes: 6 additions & 6 deletions modules/core/site.js
Original file line number Diff line number Diff line change
Expand Up @@ -917,27 +917,27 @@ function Message_List() {
};

/* TODO: remove module specific refs */
this.update_title = function() {
this.update_title = function(list_path = getListPathParam()) {
var count = 0;
var rows = Hm_Utils.rows();
var tbody = Hm_Utils.tbody();
if (getListPathParam() == 'unread') {
if (list_path == 'unread') {
count = rows.length;
document.title = count+' '+hm_trans('Unread');
}
else if (getListPathParam() == 'flagged') {
else if (list_path == 'flagged') {
count = rows.length;
document.title = count+' '+hm_trans('Flagged');
}
else if (getListPathParam() == 'combined_inbox') {
else if (list_path == 'combined_inbox') {
count = $('tr .unseen', tbody).length;
document.title = count+' '+hm_trans('Unread in Everything');
}
else if (getListPathParam() == 'email') {
else if (list_path == 'email') {
count = $('tr .unseen', tbody).length;
document.title = count+' '+hm_trans('Unread in Email');
}
else if (getListPathParam() == 'feeds') {
else if (list_path == 'feeds') {
count = $('tr .unseen', tbody).length;
document.title = count+' '+hm_trans('Unread in Feeds');
}
Expand Down
9 changes: 9 additions & 0 deletions modules/imap/js_modules/route_handlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@ function applyImapMessageListPageHandlers(routeParams) {
imap_setup_snooze();
imap_setup_tags();

$('.core_msg_control').on("click", function(e) {
e.preventDefault();
Hm_Message_List.message_action($(this).data('action'));
});
$('.toggle_link').on("click", function(e) {
e.preventDefault();
Hm_Message_List.toggle_rows();
});

if (window.githubMessageListPageHandler) githubMessageListPageHandler(routeParams);
if (window.inlineMessageMessageListAndSearchPageHandler) inlineMessageMessageListAndSearchPageHandler(routeParams);
if (window.wpMessageListPageHandler) wpMessageListPageHandler(routeParams);
Expand Down
3 changes: 3 additions & 0 deletions modules/imap/site.js
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,9 @@ var setup_imap_folder_page = async function(listPath) {
await select_imap_folder(listPath, true, true)
}

// Update browser title
Hm_Message_List.update_title(listPath);

// Refresh in the background each 30 seconds and abort any pending request when the page unmounts
const backgroundAbortController = new AbortController();
const interval = setInterval(async () => {
Expand Down
1 change: 0 additions & 1 deletion modules/inline_message/site.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ var get_inline_msg_details = function(link) {
};

var msg_inline_close = function() {
$('.refresh_link').trigger('click');
if (inline_msg_style() == 'right') {
$('.msg_text').remove();
$('.message_table').css('width', '100%');
Expand Down

0 comments on commit c39f4f0

Please sign in to comment.