From d0b8a2fd2109ac268099b3cc4b99dcbc24a0fc85 Mon Sep 17 00:00:00 2001 From: Leo Franchi Date: Tue, 23 Apr 2013 11:58:02 -0400 Subject: [PATCH] Mark messages as read when using the End key (imported from commit b2495cb27b1362d037e786db7f108540f2ce655b) --- tools/jslint/check-all.js | 2 +- zephyr/static/js/hotkey.js | 4 ++++ zephyr/static/js/ui.js | 9 +-------- zephyr/static/js/zephyr.js | 11 +++++++++++ 4 files changed, 17 insertions(+), 9 deletions(-) diff --git a/tools/jslint/check-all.js b/tools/jslint/check-all.js index 1a76ad0c88..7e6aa31fc0 100644 --- a/tools/jslint/check-all.js +++ b/tools/jslint/check-all.js @@ -42,7 +42,7 @@ var globals = + ' maybe_scroll_to_selected recenter_pointer_on_display suppress_scroll_pointer_update' + ' process_visible_unread_messages message_range message_in_table process_loaded_for_unread' + ' mark_all_as_read message_unread process_read_messages unread_in_current_view' - + ' fast_forward_pointer recent_subjects' + + ' fast_forward_pointer recent_subjects mark_read_between' ; diff --git a/zephyr/static/js/hotkey.js b/zephyr/static/js/hotkey.js index 1a2c46fbfa..05f12711ab 100644 --- a/zephyr/static/js/hotkey.js +++ b/zephyr/static/js/hotkey.js @@ -105,9 +105,13 @@ function process_hotkey(e) { } dirkey = directional_hotkeys_id[code]; var next_id = dirkey.getid(); + var prev_id = current_msg_list.selected_id(); last_viewport_movement_direction = dirkey.direction; current_msg_list.select_id(next_id, {then_scroll: true, from_scroll: true}); + if (prev_id !== -1 && next_id !== -1) { + mark_read_between(current_msg_list, prev_id, next_id); + } return true; } diff --git a/zephyr/static/js/ui.js b/zephyr/static/js/ui.js index 838e84f397..a428227b10 100644 --- a/zephyr/static/js/ui.js +++ b/zephyr/static/js/ui.js @@ -573,14 +573,7 @@ $(function () { // Make the block not empty to appease jslint var ignored = true; } else if (new_selected > scroll_start_message) { - var mark_as_read = []; - $.each(message_range(current_msg_list, scroll_start_message, new_selected), - function (idx, msg) { - if (message_unread(msg)) { - mark_as_read.push(msg); - } - }); - process_read_messages(mark_as_read); + mark_read_between(current_msg_list, scroll_start_message, new_selected); } scroll_start_message = undefined; diff --git a/zephyr/static/js/zephyr.js b/zephyr/static/js/zephyr.js index 60ad3a8ef9..88c3d4bc0c 100644 --- a/zephyr/static/js/zephyr.js +++ b/zephyr/static/js/zephyr.js @@ -419,6 +419,17 @@ function process_visible_unread_messages() { } } +function mark_read_between(msg_list, start_id, end_id) { + var mark_as_read = []; + $.each(message_range(msg_list, start_id, end_id), + function (idx, msg) { + if (message_unread(msg)) { + mark_as_read.push(msg); + } + }); + process_read_messages(mark_as_read); +} + function send_pointer_update() { if (!pointer_update_in_flight && furthest_read > server_furthest_read) {