mirror of
https://github.com/zulip/zulip.git
synced 2025-11-02 04:53:36 +00:00
hotkeys: Add left/right arrow keys to toggle views in Streams menu.
Fixes #4228
This commit is contained in:
@@ -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');
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user