Refactor how we mark a message range as read.

The goal here is to make it so that we can do other stuff with
the range of messages between two subsequent selections, besides
marking them as read.

(imported from commit f6eb07844fb2ccda195c9d4dfcdf1c15f3f40aff)
This commit is contained in:
Steve Howell 2013-07-25 16:33:08 -04:00
parent 6217c1a3be
commit 41f744c3b8
1 changed files with 6 additions and 5 deletions

View File

@ -344,9 +344,8 @@ function process_visible_unread_messages(update_cursor) {
} }
} }
function mark_read_between(msg_list, start_id, end_id) { function mark_messages_as_read(msg_list) {
var msgs_in_range = message_range(msg_list, start_id, end_id); var unread_msgs = $.grep(msg_list, unread.message_unread);
var unread_msgs = $.grep(msgs_in_range, unread.message_unread);
process_read_messages(unread_msgs); process_read_messages(unread_msgs);
} }
@ -466,11 +465,13 @@ $(function () {
if (event.mark_read && event.previously_selected !== -1) { if (event.mark_read && event.previously_selected !== -1) {
// Mark messages between old pointer and new pointer as read // Mark messages between old pointer and new pointer as read
var messages;
if (event.id < event.previously_selected) { if (event.id < event.previously_selected) {
mark_read_between(event.msg_list, event.id, event.previously_selected); messages = message_range(event.msg_list, event.id, event.previously_selected);
} else { } else {
mark_read_between(event.msg_list, event.previously_selected, event.id); messages = message_range(event.msg_list, event.previously_selected, event.id);
} }
mark_messages_as_read(messages);
} }
}); });
}); });