mirror of
https://github.com/zulip/zulip.git
synced 2025-11-15 19:31:58 +00:00
Re-focus on the compose box after a send
Re-focuses on the compose box after a send, but only if the compose-box was opened by responding to the message at the cursor (by hitting "r", enter, or clicking on the message) (imported from commit 8e7560c8ea31397b57b2bc3e2e7d9dd996226a6f)
This commit is contained in:
@@ -45,6 +45,7 @@ var globals =
|
||||
+ ' mark_all_as_read message_unread process_read_messages unread_in_current_view'
|
||||
+ ' fast_forward_pointer recent_subjects unread_subjects'
|
||||
+ ' add_message_metadata'
|
||||
+ ' respond_to_cursor'
|
||||
;
|
||||
|
||||
|
||||
|
||||
@@ -239,6 +239,7 @@ exports.cancel = function () {
|
||||
$('#restore-draft').show();
|
||||
}
|
||||
$(document).trigger($.Event('compose_canceled.zephyr'));
|
||||
respond_to_cursor = false;
|
||||
};
|
||||
|
||||
exports.empty_subject_placeholder = function() {
|
||||
@@ -355,6 +356,10 @@ function send_message() {
|
||||
clear_message_snapshot();
|
||||
$("#compose-send-button").removeAttr('disabled');
|
||||
$("#sending-indicator").hide();
|
||||
send_status.hide();
|
||||
if (respond_to_cursor) {
|
||||
respond_to_message({trigger: 'autorespond'});
|
||||
}
|
||||
},
|
||||
error: function (xhr, error_type) {
|
||||
if (error_type !== 'timeout' && reload.is_pending()) {
|
||||
@@ -369,10 +374,10 @@ function send_message() {
|
||||
response += ": " + $.parseJSON(xhr.responseText).msg;
|
||||
}
|
||||
compose_error(response, $('#new_message_content'));
|
||||
send_status.hide();
|
||||
}
|
||||
});
|
||||
|
||||
send_status.hide();
|
||||
}
|
||||
|
||||
exports.finish = function () {
|
||||
|
||||
@@ -183,9 +183,11 @@ function process_hotkey(e) {
|
||||
compose.set_mode('private');
|
||||
return true;
|
||||
case 13: // Enter: respond to message (unless we need to do something else)
|
||||
respond_to_cursor = true;
|
||||
respond_to_message({trigger: 'hotkey enter'});
|
||||
return true;
|
||||
case 114: // 'r': respond to message
|
||||
respond_to_cursor = true;
|
||||
respond_to_message({trigger: 'hotkey'});
|
||||
return true;
|
||||
case 82: // 'R': respond to author
|
||||
|
||||
@@ -1085,6 +1085,7 @@ $(function () {
|
||||
// Was a click (not a click-and-drag).
|
||||
var row = $(this).closest(".message_row");
|
||||
current_msg_list.select_id(rows.id(row));
|
||||
respond_to_cursor = true;
|
||||
respond_to_message({trigger: 'message click'});
|
||||
e.stopPropagation();
|
||||
}
|
||||
|
||||
@@ -9,6 +9,8 @@ var recent_subjects = {};
|
||||
var queued_mark_as_read = [];
|
||||
var queued_flag_timer;
|
||||
|
||||
var respond_to_cursor = false;
|
||||
|
||||
var get_updates_params = {
|
||||
pointer: -1
|
||||
};
|
||||
@@ -419,6 +421,11 @@ $(function () {
|
||||
furthest_read = event.id;
|
||||
}
|
||||
|
||||
// If we move the pointer, we don't want to respond to what's at the pointer
|
||||
if (event.previously_selected !== event.id) {
|
||||
respond_to_cursor = false;
|
||||
}
|
||||
|
||||
if (event.previously_selected !== -1) {
|
||||
// Mark messages between old pointer and new pointer as read
|
||||
if (event.id < event.previously_selected) {
|
||||
|
||||
Reference in New Issue
Block a user