Add narrow.narrow_to_next_pm_string().

This helper function will allow us to cycle through PM narrows
that are unread, once we map it to a hotkey and/or other UI.

(We intend to make something like the "n" key for topics, but
that works on PM narrows instead.)
This commit is contained in:
Steve Howell 2018-02-09 17:04:20 -05:00 committed by Tim Abbott
parent 13abed229c
commit 35cc206dcc
1 changed files with 25 additions and 0 deletions

View File

@ -362,6 +362,31 @@ exports.narrow_to_next_topic = function () {
};
exports.narrow_to_next_pm_string = function () {
var curr_pm = narrow_state.pm_string();
var next_pm = topic_generator.get_next_unread_pm_string(curr_pm);
if (!next_pm) {
return;
}
// Hopefully someday we can narrow by user_ids_string instead of
// mapping back to emails.
var pm_with = people.user_ids_string_to_emails_string(next_pm);
var filter_expr = [
{operator: 'pm-with', operand: pm_with},
];
var opts = {
select_first_unread: true,
};
exports.activate(filter_expr, opts);
};
// Activate narrowing with a single operator.
// This is just for syntactic convenience.
exports.by = function (operator, operand, opts) {