From ca0f414b607d8c30533f58396dc979fad89d8924 Mon Sep 17 00:00:00 2001 From: Leo Franchi Date: Fri, 22 Feb 2013 10:46:04 -0500 Subject: [PATCH] Fix narrowing not marking as unread when backfilling messages (imported from commit 91b164251b0c2f97bf70c0051216347e2a4616eb) --- zephyr/static/js/narrow.js | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/zephyr/static/js/narrow.js b/zephyr/static/js/narrow.js index e77f6b4b52..c1346b7d7a 100644 --- a/zephyr/static/js/narrow.js +++ b/zephyr/static/js/narrow.js @@ -241,25 +241,29 @@ exports.activate = function (operators, opts) { add_messages(all_msg_list.all(), narrowed_msg_list); } + function mark_loaded_as_unread() { + // Mark as read any messages before or at the pointer in the narrowed view + if (! narrowed_msg_list.empty()) { + // XXX: We shouldn't really be directly accessing the message list + var msgs = narrowed_msg_list.all(); + var i; + var to_process = []; + for (i = 0; i < msgs.length && msgs[i].id <= narrowed_msg_list.selected_id(); ++i) { + to_process.push(msgs[i]); + } + + process_unread_counts(to_process, true); + } + } + if (narrowed_msg_list.empty()) { load_old_messages(then_select_id, 200, 200, narrowed_msg_list, function (messages) { maybe_select_closest(); + mark_loaded_as_unread(); }, true, false); } else { maybe_select_closest(); - } - - // Mark as read any messages before or at the pointer in the narrowed view - if (! narrowed_msg_list.empty()) { - // XXX: We shouldn't really be directly accessing the message list - var msgs = narrowed_msg_list.all(); - var i; - var to_process = []; - for (i = 0; i < msgs.length && msgs[i].id <= narrowed_msg_list.selected_id(); ++i) { - to_process.push(msgs[i]); - } - - process_unread_counts(to_process, true); + mark_loaded_as_unread(); } // Show the new set of messages.