diff --git a/frontend_tests/node_tests/narrow_activate.js b/frontend_tests/node_tests/narrow_activate.js index 7c973637be..ce6c9fa4c0 100644 --- a/frontend_tests/node_tests/narrow_activate.js +++ b/frontend_tests/node_tests/narrow_activate.js @@ -130,9 +130,7 @@ function stub_message_list() { var terms = [ { operator: 'stream', operand: 'Denmark' }, ]; - var opts = { - select_first_unread: true, - }; + var opts = {}; var selected_id = 1000; @@ -144,7 +142,6 @@ function stub_message_list() { var messages = [selected_message]; - home_msg_list.selected_id = () => { return selected_id; }; current_msg_list.selected_id = () => { return -1; }; message_list.all = { @@ -152,7 +149,7 @@ function stub_message_list() { return messages; }, get: (msg_id) => { - assert.equal(msg_id, selected_id); + assert.equal(msg_id, -1); return selected_message; }, }; @@ -164,8 +161,8 @@ function stub_message_list() { assert.deepEqual(opts, { cont: opts.cont, - then_select_id: selected_id, - use_first_unread_anchor: false, + then_select_id: -1, + use_first_unread_anchor: true, }); }; diff --git a/static/js/activity.js b/static/js/activity.js index 6604675298..660d2bd888 100644 --- a/static/js/activity.js +++ b/static/js/activity.js @@ -481,13 +481,7 @@ exports.narrow_for_user = function (opts) { var user_id = buddy_list.get_key_from_li({li: opts.li}); var email = people.get_person_from_user_id(user_id).email; - var narrow_opts = { - select_first_unread: true, - trigger: 'sidebar', - }; - - narrow.by('pm-with', email, narrow_opts); - + narrow.by('pm-with', email, {trigger: 'sidebar'}); exports.clear_and_hide_search(); }; diff --git a/static/js/click_handlers.js b/static/js/click_handlers.js index 70e94411c0..c5d41cd4b0 100644 --- a/static/js/click_handlers.js +++ b/static/js/click_handlers.js @@ -347,7 +347,7 @@ $(function () { $('#group-pms').expectOne().on('click', '.selectable_sidebar_block', function (e) { var user_ids_string = $(e.target).parents('li').attr('data-user-ids'); var emails = people.user_ids_string_to_emails_string(user_ids_string); - narrow.by('pm-with', emails, {select_first_unread: true, trigger: 'sidebar'}); + narrow.by('pm-with', emails, {trigger: 'sidebar'}); e.preventDefault(); e.stopPropagation(); popovers.hide_all(); diff --git a/static/js/drafts.js b/static/js/drafts.js index b44b7a0970..63c00a3390 100644 --- a/static/js/drafts.js +++ b/static/js/drafts.js @@ -139,12 +139,12 @@ exports.restore_draft = function (draft_id) { if (draft.stream !== "") { narrow.activate([{operator: "stream", operand: draft.stream}, {operator: "topic", operand: draft.subject}], - {select_first_unread: true, trigger: "restore draft"}); + {trigger: "restore draft"}); } } else { if (draft.private_message_recipient !== "") { narrow.activate([{operator: "pm-with", operand: draft.private_message_recipient}], - {select_first_unread: true, trigger: "restore draft"}); + {trigger: "restore draft"}); } } diff --git a/static/js/hashchange.js b/static/js/hashchange.js index a143582745..43500e53d4 100644 --- a/static/js/hashchange.js +++ b/static/js/hashchange.js @@ -131,7 +131,6 @@ function do_hashchange(from_reload) { return false; } var narrow_opts = { - select_first_unread: true, change_hash: false, // already set trigger: 'hash change', }; diff --git a/static/js/hotkey.js b/static/js/hotkey.js index f239706234..1c97458393 100644 --- a/static/js/hotkey.js +++ b/static/js/hotkey.js @@ -607,7 +607,6 @@ exports.process_hotkey = function (e, hotkey) { return true; case 'narrow_private': return do_narrow_action(function (target, opts) { - opts = _.defaults({}, opts, {select_first_unread: true}); narrow.by('is', 'private', opts); }); case 'query_streams': diff --git a/static/js/narrow.js b/static/js/narrow.js index 08ac9457b1..b0346ed220 100644 --- a/static/js/narrow.js +++ b/static/js/narrow.js @@ -83,8 +83,7 @@ exports.activate = function (raw_operators, opts) { previous_id: current_msg_list.selected_id()}); opts = _.defaults({}, opts, { - then_select_id: home_msg_list.selected_id(), - select_first_unread: false, + then_select_id: -1, use_initial_narrow_pointer: false, change_hash: true, trigger: 'unknown', @@ -94,12 +93,11 @@ exports.activate = function (raw_operators, opts) { // selected and should be the center of the narrow. if (filter.has_operator("near")) { opts.then_select_id = parseInt(filter.operands("near")[0], 10); - opts.select_first_unread = false; } if (filter.has_operator("id")) { opts.then_select_id = parseInt(filter.operands("id")[0], 10); - opts.select_first_unread = false; } + opts.select_first_unread = (opts.then_select_id === -1); var then_select_id = opts.then_select_id; var then_select_offset; @@ -205,7 +203,7 @@ exports.activate = function (raw_operators, opts) { var defer_selecting_closest = message_list.narrowed.empty(); message_fetch.load_messages_for_narrow({ then_select_id: then_select_id, - use_first_unread_anchor: opts.select_first_unread && then_select_id === -1, + use_first_unread_anchor: opts.select_first_unread, cont: function () { if (defer_selecting_closest) { maybe_select_closest(); @@ -273,16 +271,10 @@ exports.stream_topic = function () { exports.activate_stream_for_cycle_hotkey = function (stream_name) { // This is the common code for A/D hotkeys. - var filter_expr = [ {operator: 'stream', operand: stream_name}, ]; - - var opts = { - select_first_unread: true, - }; - - exports.activate(filter_expr, opts); + exports.activate(filter_expr, {}); }; @@ -339,11 +331,7 @@ exports.narrow_to_next_topic = function () { {operator: 'topic', operand: next_narrow.topic}, ]; - var opts = { - select_first_unread: true, - }; - - exports.activate(filter_expr, opts); + exports.activate(filter_expr, {}); }; exports.narrow_to_next_pm_string = function () { @@ -366,7 +354,6 @@ exports.narrow_to_next_pm_string = function () { // force_close parameter is true to not auto open compose_box var opts = { - select_first_unread: true, force_close: true, }; diff --git a/static/js/notifications.js b/static/js/notifications.js index 4ce2453fb1..9cb6fa9cc1 100644 --- a/static/js/notifications.js +++ b/static/js/notifications.js @@ -267,7 +267,7 @@ function process_notification(notification) { var msg_count = 1; var notification_source; var raw_operators = []; - var opts = {select_first_unread: true, trigger: "notification click"}; + var opts = {trigger: "notification click"}; // Convert the content to plain text, replacing emoji with their alt text content = $('
').html(message.content); ui.replace_emoji_with_text(content); diff --git a/static/js/popovers.js b/static/js/popovers.js index df8a9c614b..78c5c624e6 100644 --- a/static/js/popovers.js +++ b/static/js/popovers.js @@ -585,7 +585,7 @@ exports.register_click_handlers = function () { var user_id = $(e.target).parents('ul').attr('data-user-id'); var email = people.get_person_from_user_id(user_id).email; popovers.hide_message_info_popover(); - narrow.by('pm-with', email, {select_first_unread: true, trigger: 'user sidebar popover'}); + narrow.by('pm-with', email, {trigger: 'user sidebar popover'}); e.stopPropagation(); e.preventDefault(); }); @@ -594,7 +594,7 @@ exports.register_click_handlers = function () { var user_id = $(e.target).parents('ul').attr('data-user-id'); var email = people.get_person_from_user_id(user_id).email; popovers.hide_message_info_popover(); - narrow.by('sender', email, {select_first_unread: true, trigger: 'user sidebar popover'}); + narrow.by('sender', email, {trigger: 'user sidebar popover'}); e.stopPropagation(); e.preventDefault(); }); diff --git a/static/js/search.js b/static/js/search.js index aa2467be10..18af0a6128 100644 --- a/static/js/search.js +++ b/static/js/search.js @@ -6,7 +6,7 @@ function narrow_or_search_for_term(search_string) { var search_query_box = $("#search_query"); ui_util.change_tab_to('#home'); var operators = Filter.parse(search_string); - narrow.activate(operators, {trigger: 'search', select_first_unread: true}); + narrow.activate(operators, {trigger: 'search'}); // It's sort of annoying that this is not in a position to // blur the search box, because it means that Esc won't @@ -90,8 +90,7 @@ exports.initialize = function () { // operators. (The reason the other actions don't call // this codepath is that they first all blur the box to // indicate that they've done what they need to do) - narrow.activate(Filter.parse(search_query_box.val()), {trigger: 'search', - select_first_unread: true}); + narrow.activate(Filter.parse(search_query_box.val()), {trigger: 'search'}); search_query_box.blur(); update_buttons_with_focus(false); } diff --git a/static/js/stream_list.js b/static/js/stream_list.js index ee3219dec5..0cfc5cd91b 100644 --- a/static/js/stream_list.js +++ b/static/js/stream_list.js @@ -474,8 +474,7 @@ function keydown_enter_key() { ui_util.change_tab_to('#home'); } exports.clear_and_hide_search(); - narrow.by('stream', top_stream.name, - {select_first_unread: true, trigger: 'sidebar enter key'}); + narrow.by('stream', top_stream.name, {trigger: 'sidebar enter key'}); } } @@ -520,7 +519,7 @@ exports.initialize = function () { var stream_id = $(e.target).parents('li').attr('data-stream-id'); var sub = stream_data.get_sub_by_id(stream_id); popovers.hide_all(); - narrow.by('stream', sub.name, {select_first_unread: true, trigger: 'sidebar'}); + narrow.by('stream', sub.name, {trigger: 'sidebar'}); exports.clear_and_hide_search(); diff --git a/static/js/stream_popover.js b/static/js/stream_popover.js index 7d5b9abca5..e3f95ec83c 100644 --- a/static/js/stream_popover.js +++ b/static/js/stream_popover.js @@ -226,8 +226,7 @@ exports.register_stream_handlers = function () { $('body').on('click', '.narrow_to_stream', function (e) { var sub = stream_popover_sub(e); exports.hide_stream_popover(); - narrow.by('stream', sub.name, - {select_first_unread: true, trigger: 'sidebar popover'} + narrow.by('stream', sub.name, {trigger: 'sidebar popover'} ); e.stopPropagation(); }); @@ -335,8 +334,7 @@ exports.register_topic_handlers = function () { {operator: 'stream', operand: sub.name}, {operator: 'topic', operand: topic}, ]; - var opts = {select_first_unread: true, trigger: 'sidebar'}; - narrow.activate(operators, opts); + narrow.activate(operators, {trigger: 'sidebar'}); e.stopPropagation(); }); diff --git a/static/js/topic_list.js b/static/js/topic_list.js index c1f28e9773..e071fff008 100644 --- a/static/js/topic_list.js +++ b/static/js/topic_list.js @@ -303,7 +303,7 @@ exports.set_click_handlers = function (callbacks) { narrow.activate([{operator: 'stream', operand: sub.name}, {operator: 'topic', operand: topic}], - {select_first_unread: true, trigger: 'sidebar'}); + {trigger: 'sidebar'}); e.preventDefault(); }); diff --git a/static/js/tutorial.js b/static/js/tutorial.js index e073c67629..a51e2ef455 100644 --- a/static/js/tutorial.js +++ b/static/js/tutorial.js @@ -13,7 +13,7 @@ function set_tutorial_status(status, callback) { exports.initialize = function () { if (page_params.needs_tutorial) { set_tutorial_status("started"); - narrow.by('is', 'private', {select_first_unread: true, trigger: 'sidebar'}); + narrow.by('is', 'private', {trigger: 'sidebar'}); } };