mirror of
https://github.com/zulip/zulip.git
synced 2025-11-08 16:01:58 +00:00
narrow: Migrate uses of by function to activate function.
This is part of renaming effort of `narrow` to `message_view`.
This commit is contained in:
@@ -925,7 +925,15 @@ export function process_hotkey(e, hotkey) {
|
|||||||
// Shortcuts that don't require a message
|
// Shortcuts that don't require a message
|
||||||
switch (event_name) {
|
switch (event_name) {
|
||||||
case "narrow_private":
|
case "narrow_private":
|
||||||
narrow.by("is", "dm", {trigger: "hotkey"});
|
narrow.activate(
|
||||||
|
[
|
||||||
|
{
|
||||||
|
operator: "is",
|
||||||
|
operand: "dm",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
{trigger: "hotkey"},
|
||||||
|
);
|
||||||
return true;
|
return true;
|
||||||
case "query_streams":
|
case "query_streams":
|
||||||
stream_list.initiate_search();
|
stream_list.initiate_search();
|
||||||
|
|||||||
@@ -997,12 +997,6 @@ export function narrow_to_next_pm_string(opts = {}) {
|
|||||||
activate(filter_expr, updated_opts);
|
activate(filter_expr, updated_opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Activate narrowing with a single operator.
|
|
||||||
// This is just for syntactic convenience.
|
|
||||||
export function by(operator, operand, opts) {
|
|
||||||
activate([{operator, operand}], opts);
|
|
||||||
}
|
|
||||||
|
|
||||||
export function by_topic(target_id, opts) {
|
export function by_topic(target_id, opts) {
|
||||||
// don't use message_lists.current as it won't work for muted messages or for out-of-narrow links
|
// don't use message_lists.current as it won't work for muted messages or for out-of-narrow links
|
||||||
const original = message_store.get(target_id);
|
const original = message_store.get(target_id);
|
||||||
@@ -1050,7 +1044,7 @@ export function by_recipient(target_id, opts) {
|
|||||||
// in the new view.
|
// in the new view.
|
||||||
unread_ops.notify_server_message_read(message);
|
unread_ops.notify_server_message_read(message);
|
||||||
}
|
}
|
||||||
by("dm", message.reply_to, opts);
|
activate([{operator: "dm", operand: message.reply_to}], opts);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "stream":
|
case "stream":
|
||||||
@@ -1064,7 +1058,15 @@ export function by_recipient(target_id, opts) {
|
|||||||
// in the new view.
|
// in the new view.
|
||||||
unread_ops.notify_server_message_read(message);
|
unread_ops.notify_server_message_read(message);
|
||||||
}
|
}
|
||||||
by("stream", stream_data.get_stream_name_from_id(message.stream_id), opts);
|
activate(
|
||||||
|
[
|
||||||
|
{
|
||||||
|
operator: "stream",
|
||||||
|
operand: stream_data.get_stream_name_from_id(message.stream_id),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
opts,
|
||||||
|
);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1104,10 +1106,10 @@ export function to_compose_target() {
|
|||||||
// If there are no recipients or any recipient is
|
// If there are no recipients or any recipient is
|
||||||
// invalid, narrow to your direct message feed.
|
// invalid, narrow to your direct message feed.
|
||||||
if (emails.length === 0 || invalid.length > 0) {
|
if (emails.length === 0 || invalid.length > 0) {
|
||||||
by("is", "dm", opts);
|
activate([{operator: "is", operand: "dm"}], opts);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
by("dm", util.normalize_recipients(recipient_string), opts);
|
activate([{operator: "dm", operand: util.normalize_recipients(recipient_string)}], opts);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -79,7 +79,15 @@ export function initialize() {
|
|||||||
$popper.one("click", ".narrow-self-direct-message", (e) => {
|
$popper.one("click", ".narrow-self-direct-message", (e) => {
|
||||||
const user_id = current_user.user_id;
|
const user_id = current_user.user_id;
|
||||||
const email = people.get_by_user_id(user_id).email;
|
const email = people.get_by_user_id(user_id).email;
|
||||||
narrow.by("dm", email, {trigger: "personal menu"});
|
narrow.activate(
|
||||||
|
[
|
||||||
|
{
|
||||||
|
operator: "dm",
|
||||||
|
operand: email,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
{trigger: "personal menu"},
|
||||||
|
);
|
||||||
popovers.hide_all();
|
popovers.hide_all();
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
});
|
});
|
||||||
@@ -87,7 +95,15 @@ export function initialize() {
|
|||||||
$popper.one("click", ".narrow-messages-sent", (e) => {
|
$popper.one("click", ".narrow-messages-sent", (e) => {
|
||||||
const user_id = current_user.user_id;
|
const user_id = current_user.user_id;
|
||||||
const email = people.get_by_user_id(user_id).email;
|
const email = people.get_by_user_id(user_id).email;
|
||||||
narrow.by("sender", email, {trigger: "personal menu"});
|
narrow.activate(
|
||||||
|
[
|
||||||
|
{
|
||||||
|
operator: "sender",
|
||||||
|
operand: email,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
{trigger: "personal menu"},
|
||||||
|
);
|
||||||
popovers.hide_all();
|
popovers.hide_all();
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -13,6 +13,14 @@ function set_tutorial_status(status, callback) {
|
|||||||
export function initialize() {
|
export function initialize() {
|
||||||
if (page_params.needs_tutorial) {
|
if (page_params.needs_tutorial) {
|
||||||
set_tutorial_status("started");
|
set_tutorial_status("started");
|
||||||
narrow.by("is", "private", {trigger: "sidebar"});
|
narrow.activate(
|
||||||
|
[
|
||||||
|
{
|
||||||
|
operator: "is",
|
||||||
|
operand: "private",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
{trigger: "sidebar"},
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -774,7 +774,15 @@ export function initialize_everything(state_data) {
|
|||||||
const sub = sub_store.get(stream_id);
|
const sub = sub_store.get(stream_id);
|
||||||
sidebar_ui.hide_all();
|
sidebar_ui.hide_all();
|
||||||
popovers.hide_all();
|
popovers.hide_all();
|
||||||
narrow.by("stream", sub.name, {trigger});
|
narrow.activate(
|
||||||
|
[
|
||||||
|
{
|
||||||
|
operator: "stream",
|
||||||
|
operand: sub.name,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
{trigger},
|
||||||
|
);
|
||||||
activity_ui.build_user_sidebar();
|
activity_ui.build_user_sidebar();
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@@ -851,7 +859,15 @@ export function initialize_everything(state_data) {
|
|||||||
activity.initialize();
|
activity.initialize();
|
||||||
activity_ui.initialize({
|
activity_ui.initialize({
|
||||||
narrow_by_email(email) {
|
narrow_by_email(email) {
|
||||||
narrow.by("dm", email, {trigger: "sidebar"});
|
narrow.activate(
|
||||||
|
[
|
||||||
|
{
|
||||||
|
operator: "dm",
|
||||||
|
operand: email,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
{trigger: "sidebar"},
|
||||||
|
);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
// This needs to happen after activity_ui.initialize, so that user_filter
|
// This needs to happen after activity_ui.initialize, so that user_filter
|
||||||
|
|||||||
@@ -688,7 +688,15 @@ function register_click_handlers() {
|
|||||||
$("body").on("click", ".user-card-popover-actions .narrow_to_private_messages", (e) => {
|
$("body").on("click", ".user-card-popover-actions .narrow_to_private_messages", (e) => {
|
||||||
const user_id = elem_to_user_id($(e.target).parents("ul"));
|
const user_id = elem_to_user_id($(e.target).parents("ul"));
|
||||||
const email = people.get_by_user_id(user_id).email;
|
const email = people.get_by_user_id(user_id).email;
|
||||||
narrow.by("dm", email, {trigger: "user sidebar popover"});
|
narrow.activate(
|
||||||
|
[
|
||||||
|
{
|
||||||
|
operator: "dm",
|
||||||
|
operand: email,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
{trigger: "user sidebar popover"},
|
||||||
|
);
|
||||||
hide_all();
|
hide_all();
|
||||||
if (overlays.any_active()) {
|
if (overlays.any_active()) {
|
||||||
overlays.close_active();
|
overlays.close_active();
|
||||||
@@ -700,7 +708,15 @@ function register_click_handlers() {
|
|||||||
$("body").on("click", ".user-card-popover-actions .narrow_to_messages_sent", (e) => {
|
$("body").on("click", ".user-card-popover-actions .narrow_to_messages_sent", (e) => {
|
||||||
const user_id = elem_to_user_id($(e.target).parents("ul"));
|
const user_id = elem_to_user_id($(e.target).parents("ul"));
|
||||||
const email = people.get_by_user_id(user_id).email;
|
const email = people.get_by_user_id(user_id).email;
|
||||||
narrow.by("sender", email, {trigger: "user sidebar popover"});
|
narrow.activate(
|
||||||
|
[
|
||||||
|
{
|
||||||
|
operator: "sender",
|
||||||
|
operand: email,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
{trigger: "user sidebar popover"},
|
||||||
|
);
|
||||||
hide_all();
|
hide_all();
|
||||||
if (overlays.any_active()) {
|
if (overlays.any_active()) {
|
||||||
overlays.close_active();
|
overlays.close_active();
|
||||||
|
|||||||
@@ -318,7 +318,7 @@ run_test("basic mappings", () => {
|
|||||||
|
|
||||||
assert_mapping("c", compose_actions, "start");
|
assert_mapping("c", compose_actions, "start");
|
||||||
assert_mapping("x", compose_actions, "start");
|
assert_mapping("x", compose_actions, "start");
|
||||||
assert_mapping("P", narrow, "by");
|
assert_mapping("P", narrow, "activate");
|
||||||
assert_mapping("g", gear_menu, "toggle");
|
assert_mapping("g", gear_menu, "toggle");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user