mirror of https://github.com/zulip/zulip.git
compose_actions.js: Allow compose to empty narrow.
This allows r/enter hotkeys to compose to an empty narrow (no messages). Fixes #4500.
This commit is contained in:
parent
c4914eeec9
commit
ac64ee355d
|
@ -215,7 +215,7 @@ function stubbing(func_name_to_stub, test_function) {
|
|||
assert_mapping('d', 'drafts.toggle');
|
||||
|
||||
// Next, test keys that only work on a selected message.
|
||||
var message_view_only_keys = '@*+rRjJkKsSuvi:GM';
|
||||
var message_view_only_keys = '@*+RjJkKsSuvi:GM';
|
||||
|
||||
// Check that they do nothing without a selected message
|
||||
global.current_msg_list.empty = return_true;
|
||||
|
|
|
@ -252,7 +252,21 @@ exports.respond_to_message = function (opts) {
|
|||
|
||||
message = current_msg_list.selected_message();
|
||||
|
||||
if (message === undefined) {
|
||||
if (message === undefined) { // empty narrow implementation
|
||||
if (!narrow_state.narrowed_by_pm_reply() &&
|
||||
!narrow_state.narrowed_by_stream_reply() &&
|
||||
!narrow_state.narrowed_by_topic_reply()) {
|
||||
return;
|
||||
}
|
||||
|
||||
msg_type = 'stream'; // Set msg_type to stream by default
|
||||
// in the case of an empty home view.
|
||||
if (narrow_state.narrowed_by_pm_reply()) {
|
||||
msg_type = 'private';
|
||||
}
|
||||
|
||||
var new_opts = fill_in_opts_from_current_narrowed_view(msg_type, opts);
|
||||
exports.start(new_opts.message_type, new_opts);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -321,14 +321,9 @@ exports.process_enter_key = function (e) {
|
|||
return true;
|
||||
}
|
||||
|
||||
if (current_msg_list.empty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// If we got this far, then we're presumably in the message
|
||||
// view and there is a "current" message, so in that case
|
||||
// "enter" is the hotkey to respond to a message. Note that
|
||||
// "r" has same effect, but that is handled in process_hotkey().
|
||||
// view, so in that case "enter" is the hotkey to respond to a message.
|
||||
// Note that "r" has same effect, but that is handled in process_hotkey().
|
||||
compose_actions.respond_to_message({trigger: 'hotkey enter'});
|
||||
return true;
|
||||
};
|
||||
|
@ -589,6 +584,11 @@ exports.process_hotkey = function (e, hotkey) {
|
|||
case 'open_drafts':
|
||||
drafts.toggle();
|
||||
return true;
|
||||
case 'reply_message': // 'r': respond to message
|
||||
// Note that you can "enter" to respond to messages as well,
|
||||
// but that is handled in process_enter_key().
|
||||
compose_actions.respond_to_message({trigger: 'hotkey'});
|
||||
return true;
|
||||
}
|
||||
|
||||
if (current_msg_list.empty()) {
|
||||
|
@ -640,11 +640,6 @@ exports.process_hotkey = function (e, hotkey) {
|
|||
return do_narrow_action(narrow.by_recipient);
|
||||
case 'narrow_by_subject':
|
||||
return do_narrow_action(narrow.by_subject);
|
||||
case 'reply_message': // 'r': respond to message
|
||||
// Note that you can "enter" to respond to messages as well,
|
||||
// but that is handled in process_enter_key().
|
||||
compose_actions.respond_to_message({trigger: 'hotkey'});
|
||||
return true;
|
||||
case 'respond_to_author': // 'R': respond to author
|
||||
compose_actions.respond_to_message({reply_type: "personal", trigger: 'hotkey pm'});
|
||||
return true;
|
||||
|
|
Loading…
Reference in New Issue