Move respond_to_message to compose.js.

This commit is contained in:
Vishnu Ks 2016-06-29 03:57:50 +05:30 committed by Tim Abbott
parent def8cd8e78
commit e4b72c3a65
6 changed files with 46 additions and 52 deletions

View File

@ -57,7 +57,7 @@ $(function () {
}
current_msg_list.select_id(id);
respond_to_message({trigger: 'message click'});
compose.respond_to_message({trigger: 'message click'});
e.stopPropagation();
popovers.hide_all();
}

View File

@ -598,6 +598,46 @@ function send_message(request) {
}
}
exports.respond_to_message = function (opts) {
var message, msg_type;
// Before initiating a reply to a message, if there's an
// in-progress composition, snapshot it.
compose.snapshot_message();
message = current_msg_list.selected_message();
if (message === undefined) {
return;
}
unread.mark_message_as_read(message);
var stream = '';
var subject = '';
if (message.type === "stream") {
stream = message.stream;
subject = message.subject;
}
var pm_recipient = message.reply_to;
if (opts.reply_type === "personal" && message.type === "private") {
// reply_to for private messages is everyone involved, so for
// personals replies we need to set the the private message
// recipient to just the sender
pm_recipient = message.sender_email;
}
if (opts.reply_type === 'personal' || message.type === 'private') {
msg_type = 'private';
} else {
msg_type = message.type;
}
compose.start(msg_type, {'stream': stream, 'subject': subject,
'private_message_recipient': pm_recipient,
'replying_to_message': message,
'trigger': opts.trigger});
};
// This function is for debugging / data collection only. Arguably it
// should live in debug.js, but then it wouldn't be able to call
// send_message() directly below.

View File

@ -306,13 +306,13 @@ function process_hotkey(e) {
case 'narrow_by_subject':
return do_narrow_action(narrow.by_subject);
case 'enter': // Enter: respond to message (unless we need to do something else)
respond_to_message({trigger: 'hotkey enter'});
compose.respond_to_message({trigger: 'hotkey enter'});
return true;
case 'reply_message': // 'r': respond to message
respond_to_message({trigger: 'hotkey'});
compose.respond_to_message({trigger: 'hotkey'});
return true;
case 'respond_to_author': // 'R': respond to author
respond_to_message({reply_type: "personal", trigger: 'hotkey pm'});
compose.respond_to_message({reply_type: "personal", trigger: 'hotkey pm'});
return true;
}

View File

@ -459,13 +459,13 @@ exports.register_click_handlers = function () {
});
$('body').on('click', '.respond_button', function (e) {
respond_to_message({trigger: 'popover respond'});
compose.respond_to_message({trigger: 'popover respond'});
popovers.hide_actions_popover();
e.stopPropagation();
e.preventDefault();
});
$('body').on('click', '.respond_personal_button', function (e) {
respond_to_message({reply_type: 'personal', trigger: 'popover respond pm'});
compose.respond_to_message({reply_type: 'personal', trigger: 'popover respond pm'});
popovers.hide_all();
e.stopPropagation();
e.preventDefault();

View File

@ -10,51 +10,6 @@ var current_msg_list = home_msg_list;
var queued_mark_as_read = [];
var queued_flag_timer;
function respond_to_message(opts) {
var message, msg_type;
// Before initiating a reply to a message, if there's an
// in-progress composition, snapshot it.
compose.snapshot_message();
message = current_msg_list.selected_message();
if (message === undefined) {
return;
}
unread.mark_message_as_read(message);
var stream = '';
var subject = '';
if (message.type === "stream") {
stream = message.stream;
subject = message.subject;
}
var pm_recipient = message.reply_to;
if (opts.reply_type === "personal" && message.type === "private") {
// reply_to for private messages is everyone involved, so for
// personals replies we need to set the the private message
// recipient to just the sender
pm_recipient = message.sender_email;
}
if (opts.reply_type === 'personal' || message.type === 'private') {
msg_type = 'private';
} else {
msg_type = message.type;
}
compose.start(msg_type, {'stream': stream, 'subject': subject,
'private_message_recipient': pm_recipient,
'replying_to_message': message,
'trigger': opts.trigger});
}
function consider_bankruptcy() {
// Until we've handled possibly declaring bankruptcy, don't show
// unread counts since they only consider messages that are loaded

View File

@ -54,7 +54,6 @@ var globals =
// zulip.js
+ ' home_msg_list current_msg_list'
+ ' respond_to_message'
+ ' process_loaded_for_unread'
;