mirror of
https://github.com/zulip/zulip.git
synced 2025-11-06 06:53:25 +00:00
narrow: Remove unnecessary select_first_unread option.
We consistently either pass a `then_select_id` into narrow.activate, or were using the select_first_unread option. Now, we just compute select_first_unread based on the value of then_select_id.
This commit is contained in:
@@ -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,
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -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();
|
||||
};
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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"});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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',
|
||||
};
|
||||
|
||||
@@ -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':
|
||||
|
||||
@@ -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,
|
||||
};
|
||||
|
||||
|
||||
@@ -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 = $('<div/>').html(message.content);
|
||||
ui.replace_emoji_with_text(content);
|
||||
|
||||
@@ -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();
|
||||
});
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -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();
|
||||
});
|
||||
|
||||
@@ -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();
|
||||
});
|
||||
|
||||
@@ -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'});
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user