hotkeys: Add left/right arrow keys to toggle views in Streams menu.

Fixes #4228
This commit is contained in:
Cynthia Lin
2017-03-22 22:02:01 -07:00
committed by Tim Abbott
parent fb89d8a2bf
commit b800cb05c0
3 changed files with 22 additions and 5 deletions

View File

@@ -291,16 +291,15 @@ function stubbing(func_name_to_stub, test_function) {
assert_mapping('spacebar', 'navigate.page_down');
assert_mapping('up_arrow', 'navigate.up');
hotkey.is_lightbox_open = return_true;
assert_mapping('left_arrow', 'lightbox.prev');
assert_mapping('right_arrow', 'lightbox.next');
hotkey.is_subs = return_true;
global.ui_state.home_tab_obscured = return_true;
assert_mapping('up_arrow', 'subs.switch_rows');
assert_mapping('down_arrow', 'subs.switch_rows');
global.ui_state.home_tab_obscured = return_false;
hotkey.is_subs = return_false;
hotkey.is_lightbox_open = return_true;
assert_mapping('left_arrow', 'lightbox.prev');
assert_mapping('right_arrow', 'lightbox.next');
hotkey.is_settings_page = return_true;
assert_unmapped('end');

View File

@@ -530,6 +530,9 @@ exports.process_hotkey = function (e, hotkey) {
if (exports.is_lightbox_open()) {
lightbox.prev();
return true;
} else if (exports.is_subs()) {
subs.toggle_view(event_name);
return true;
}
message_edit.edit_last_sent_message();
@@ -540,6 +543,9 @@ exports.process_hotkey = function (e, hotkey) {
if (exports.is_lightbox_open()) {
lightbox.next();
return true;
} else if (exports.is_subs()) {
subs.toggle_view(event_name);
return true;
}
}

View File

@@ -761,6 +761,18 @@ exports.keyboard_sub = function () {
}
};
exports.toggle_view = function (event) {
var active_data = get_active_data();
var hash;
if (event === 'right_arrow' && active_data[2].text() === 'Subscribed') {
hash = ['#streams', 'all'];
export_hash(hash);
} else if (event === 'left_arrow' && active_data[2].text() === 'All streams') {
hash = ['#streams', 'subscribed'];
export_hash(hash);
}
};
function ajaxSubscribe(stream) {
// Subscribe yourself to a single stream.
var true_stream_name;