click_handlers: Refactor select_message_function.

This uses the early-return pattern to make the main click handler for
opening the compose box more readable.
This commit is contained in:
Pranav 2020-04-10 16:35:11 +05:30 committed by Tim Abbott
parent ce9f21545a
commit 3f47c0f8bc
1 changed files with 16 additions and 13 deletions

View File

@ -85,20 +85,23 @@ exports.initialize = function () {
return;
}
if (!(document.getSelection().type === "Range")) {
const row = $(this).closest(".message_row");
const id = rows.id(row);
if (message_edit.is_editing(id)) {
// Clicks on a message being edited shouldn't trigger a reply.
return;
}
current_msg_list.select_id(id);
compose_actions.respond_to_message({trigger: 'message click'});
e.stopPropagation();
popovers.hide_all();
if (document.getSelection().type === "Range") {
// Drags on the message (to copy message text) shouldn't trigger a reply.
return;
}
const row = $(this).closest(".message_row");
const id = rows.id(row);
if (message_edit.is_editing(id)) {
// Clicks on a message being edited shouldn't trigger a reply.
return;
}
current_msg_list.select_id(id);
compose_actions.respond_to_message({trigger: 'message click'});
e.stopPropagation();
popovers.hide_all();
};
// if on normal non-mobile experience, a `click` event should run the message