mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-04 05:53:43 +00:00 
			
		
		
		
	hotkeys: Simplify up/down handling for stream settings.
We've had this kind of hacky setting called message_view_only for a long time in the hotkeys code, and it originally helped optimize the code a bit. It wasn't well maintained, and people started adding non-message-view behavior to the arrow keys without flipping that flag to false. This change finally flips the flag to false, which simplifies some of our logic.
This commit is contained in:
		@@ -307,16 +307,15 @@ function stubbing(func_name_to_stub, test_function) {
 | 
			
		||||
    assert_mapping('up_arrow', 'navigate.up');
 | 
			
		||||
 | 
			
		||||
    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_lightbox_open = return_true;
 | 
			
		||||
    assert_mapping('left_arrow', 'lightbox.prev');
 | 
			
		||||
    assert_mapping('right_arrow', 'lightbox.next');
 | 
			
		||||
 | 
			
		||||
    hotkey.is_editing_stream_name = return_true;
 | 
			
		||||
    hotkey.is_subs = return_false;
 | 
			
		||||
    assert_unmapped('down_arrow');
 | 
			
		||||
    assert_unmapped('up_arrow');
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -66,8 +66,8 @@ var keydown_unshift_mappings = {
 | 
			
		||||
    36: {name: 'home', message_view_only: true}, // home
 | 
			
		||||
    37: {name: 'left_arrow', message_view_only: false}, // left arrow
 | 
			
		||||
    39: {name: 'right_arrow', message_view_only: false}, // right arrow
 | 
			
		||||
    38: {name: 'up_arrow', message_view_only: true}, // up arrow
 | 
			
		||||
    40: {name: 'down_arrow', message_view_only: true}, // down arrow
 | 
			
		||||
    38: {name: 'up_arrow', message_view_only: false}, // up arrow
 | 
			
		||||
    40: {name: 'down_arrow', message_view_only: false}, // down arrow
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
var keydown_ctrl_mappings = {
 | 
			
		||||
@@ -457,12 +457,13 @@ exports.process_hotkey = function (e, hotkey) {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (hotkey.message_view_only && ui_state.home_tab_obscured()) {
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if ((event_name === 'up_arrow' || event_name === 'down_arrow') && exports.is_subs()) {
 | 
			
		||||
        subs.switch_rows(event_name);
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (exports.is_editing_stream_name(e)) {
 | 
			
		||||
        // We handle the enter key in process_enter_key().
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user