mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-03 21:43:21 +00:00 
			
		
		
		
	Allow cycling between streams with shift+{A,D}
Closes trac #2273. (imported from commit 858ffd47aa6dbb372d426fe94b860dfe1c1cce34)
This commit is contained in:
		@@ -67,8 +67,12 @@ function get_event_name(e) {
 | 
				
			|||||||
        return 'search';
 | 
					        return 'search';
 | 
				
			||||||
    case 63: // '?': Show keyboard shortcuts page
 | 
					    case 63: // '?': Show keyboard shortcuts page
 | 
				
			||||||
        return 'show_shortcuts';
 | 
					        return 'show_shortcuts';
 | 
				
			||||||
 | 
					    case 65: // 'A'
 | 
				
			||||||
 | 
					        return 'stream_cycle_backward';
 | 
				
			||||||
    case 67: // 'C'
 | 
					    case 67: // 'C'
 | 
				
			||||||
        return 'compose_private_message';
 | 
					        return 'compose_private_message';
 | 
				
			||||||
 | 
					    case 68: // 'D'
 | 
				
			||||||
 | 
					        return 'stream_cycle_forward';
 | 
				
			||||||
    case 74: // 'J'
 | 
					    case 74: // 'J'
 | 
				
			||||||
        return 'page_down';
 | 
					        return 'page_down';
 | 
				
			||||||
    case 75: // 'K'
 | 
					    case 75: // 'K'
 | 
				
			||||||
@@ -271,6 +275,12 @@ function process_hotkey(e) {
 | 
				
			|||||||
        case 'show_shortcuts': // Show keyboard shortcuts page
 | 
					        case 'show_shortcuts': // Show keyboard shortcuts page
 | 
				
			||||||
            $('#keyboard-shortcuts').modal('show');
 | 
					            $('#keyboard-shortcuts').modal('show');
 | 
				
			||||||
            return true;
 | 
					            return true;
 | 
				
			||||||
 | 
					        case 'stream_cycle_backward':
 | 
				
			||||||
 | 
					            navigate.cycle_stream('backward');
 | 
				
			||||||
 | 
					            return true;
 | 
				
			||||||
 | 
					        case 'stream_cycle_forward':
 | 
				
			||||||
 | 
					            navigate.cycle_stream('forward');
 | 
				
			||||||
 | 
					            return true;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (current_msg_list.empty()) {
 | 
					    if (current_msg_list.empty()) {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -70,5 +70,37 @@ exports.page_down = function () {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					exports.cycle_stream = function (direction) {
 | 
				
			||||||
 | 
					    var currentStream, nextStream;
 | 
				
			||||||
 | 
					    if (narrow.stream() !== undefined) {
 | 
				
			||||||
 | 
					        currentStream = stream_list.get_stream_li(narrow.stream());
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    switch (direction) {
 | 
				
			||||||
 | 
					        case 'forward':
 | 
				
			||||||
 | 
					            if (narrow.stream() === undefined) {
 | 
				
			||||||
 | 
					                nextStream = $("#stream_filters").children().first();
 | 
				
			||||||
 | 
					            } else {
 | 
				
			||||||
 | 
					                nextStream = currentStream.next();
 | 
				
			||||||
 | 
					                if (nextStream.length === 0) {
 | 
				
			||||||
 | 
					                    nextStream = $("#stream_filters").children().first();
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            break;
 | 
				
			||||||
 | 
					        case 'backward':
 | 
				
			||||||
 | 
					            if (narrow.stream() === undefined) {
 | 
				
			||||||
 | 
					                nextStream = $("#stream_filters").children().last();
 | 
				
			||||||
 | 
					            } else {
 | 
				
			||||||
 | 
					                nextStream = currentStream.prev();
 | 
				
			||||||
 | 
					                if (nextStream.length === 0) {
 | 
				
			||||||
 | 
					                    nextStream = $("#stream_filters").children().last();
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            break;
 | 
				
			||||||
 | 
					        default:
 | 
				
			||||||
 | 
					            blueslip.error("Invalid parameter to cycle_stream", {value: direction});
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    narrow.by('stream', nextStream.data('name'));
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
return exports;
 | 
					return exports;
 | 
				
			||||||
}());
 | 
					}());
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -94,6 +94,10 @@
 | 
				
			|||||||
          <td class="hotkey">v</td>
 | 
					          <td class="hotkey">v</td>
 | 
				
			||||||
          <td class="definition">Narrow to all private messages</td>
 | 
					          <td class="definition">Narrow to all private messages</td>
 | 
				
			||||||
        </tr>
 | 
					        </tr>
 | 
				
			||||||
 | 
					        <tr>
 | 
				
			||||||
 | 
					          <td class="hotkey">A or D</td>
 | 
				
			||||||
 | 
					          <td class="definition">Cycle between stream narrows</td>
 | 
				
			||||||
 | 
					        </tr>
 | 
				
			||||||
        <tr>
 | 
					        <tr>
 | 
				
			||||||
          <td class="hotkey">Esc</td>
 | 
					          <td class="hotkey">Esc</td>
 | 
				
			||||||
          <td class="definition">Return to home view</td>
 | 
					          <td class="definition">Return to home view</td>
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user