hotkey: Add hotkey to narrow to starred messages.

Fixes #9684.
This commit is contained in:
Joshua Pan 2018-08-12 22:02:00 -07:00 committed by Tim Abbott
parent 71d81371fc
commit 144d21494e
4 changed files with 27 additions and 3 deletions

View File

@ -70,12 +70,13 @@ run_test('mappings', () => {
});
}
function map_down(which, shiftKey, ctrlKey, metaKey) {
function map_down(which, shiftKey, ctrlKey, metaKey, altKey) {
return hotkey.get_keydown_hotkey({
which: which,
shiftKey: shiftKey,
ctrlKey: ctrlKey,
metaKey: metaKey,
altKey: altKey,
});
}
@ -124,6 +125,7 @@ run_test('mappings', () => {
assert.equal(map_down(75, true, true), undefined); // shift + ctrl + k
assert.equal(map_down(83, true, true), undefined); // shift + ctrl + s
assert.equal(map_down(219, true, true, false), undefined); // shift + ctrl + [
assert.equal(map_down(83, false, false, false, true), undefined); // alt + s
// CMD tests for MacOS
global.navigator.userAgent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.167 Safari/537.36";
@ -135,6 +137,8 @@ run_test('mappings', () => {
assert.equal(map_down(83, false, true, false), undefined); // ctrl + s
// Reset userAgent
global.navigator.userAgent = '';
assert.equal(map_down(83, false, true, false, true).name, 'narrow_starred'); // ctrl + alt + s
});
run_test('basic_chars', () => {

View File

@ -111,13 +111,23 @@ var keypress_mappings = {
120: {name: 'compose_private_message', message_view_only: true}, // 'x'
};
var keydown_ctrl_alt_mappings = {
83: {name: 'narrow_starred', message_view_only: true}, // 's'
};
exports.get_keydown_hotkey = function (e) {
var hotkey;
if (e.altKey) {
if (e.ctrlKey) {
hotkey = keydown_ctrl_alt_mappings[e.which];
if (hotkey) {
return hotkey;
}
}
return;
}
var hotkey;
if (e.ctrlKey && !e.shiftKey) {
hotkey = keydown_ctrl_mappings[e.which];
if (hotkey) {
@ -626,6 +636,10 @@ exports.process_hotkey = function (e, hotkey) {
return do_narrow_action(function (target, opts) {
narrow.by('is', 'private', opts);
});
case 'narrow_starred':
return do_narrow_action(function (target, opts) {
narrow.by('is', 'starred', opts);
});
case 'query_streams':
stream_list.initiate_search();
return true;

View File

@ -170,6 +170,10 @@
<td class="hotkey">P</td>
<td class="definition">{% trans %}Narrow to all private messages{% endtrans %}</td>
</tr>
<tr>
<td class="hotkey">Ctrl + Alt + s</td>
<td class="definition">{% trans %}Narrow to starred messages{% endtrans %}</td>
</tr>
<tr>
<td class="hotkey">n</td>
<td class="definition">{% trans %}Narrow to next unread topic{% endtrans %}</td>

View File

@ -76,6 +76,8 @@ below, and add more to your repertoire as needed.
* **Narrow to all private messages**: `P`
* **Narrow to starred messages**: `Ctrl + Alt + s`
* **Cycle between stream narrows**: `A` (previous) and `D` (next)
* **Narrow to all messages**: `Esc` or `Ctrl` + `[` — Shows all unmuted messages.