narrow: Add hotkey trigger for navigation to new topic/direct message.

Adds including a trigger to the opts for narrow_to_next_topic and
narrow_to_next_pm_string when called from `web/src/hotkey.js`.
This commit is contained in:
Lauryn Menard 2023-07-21 15:55:11 +02:00 committed by Tim Abbott
parent 0652efc473
commit 02c279c6b6
2 changed files with 8 additions and 7 deletions

View File

@ -863,10 +863,10 @@ export function process_hotkey(e, hotkey) {
narrow.stream_cycle_forward();
return true;
case "n_key":
narrow.narrow_to_next_topic();
narrow.narrow_to_next_topic({trigger: "hotkey"});
return true;
case "p_key":
narrow.narrow_to_next_pm_string();
narrow.narrow_to_next_pm_string({trigger: "hotkey"});
return true;
case "open_recent_topics":
browser_history.go_to_location("#recent");

View File

@ -832,7 +832,7 @@ export function stream_cycle_forward() {
activate_stream_for_cycle_hotkey(stream_name);
}
export function narrow_to_next_topic() {
export function narrow_to_next_topic(opts = {}) {
const curr_info = {
stream: narrow_state.stream(),
topic: narrow_state.topic(),
@ -849,10 +849,10 @@ export function narrow_to_next_topic() {
{operator: "topic", operand: next_narrow.topic},
];
activate(filter_expr, {});
activate(filter_expr, opts);
}
export function narrow_to_next_pm_string() {
export function narrow_to_next_pm_string(opts = {}) {
const current_direct_message = narrow_state.pm_ids_string();
const next_direct_message = topic_generator.get_next_unread_pm_string(current_direct_message);
@ -868,11 +868,12 @@ export function narrow_to_next_pm_string() {
const filter_expr = [{operator: "dm", operand: direct_message}];
// force_close parameter is true to not auto open compose_box
const opts = {
const updated_opts = {
...opts,
force_close: true,
};
activate(filter_expr, opts);
activate(filter_expr, updated_opts);
}
// Activate narrowing with a single operator.