mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-04 14:03:30 +00:00 
			
		
		
		
	Move respond_to_message to compose.js.
This commit is contained in:
		@@ -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();
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
@@ -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.
 | 
			
		||||
 
 | 
			
		||||
@@ -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;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -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();
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
 
 | 
			
		||||
@@ -54,7 +54,6 @@ var globals =
 | 
			
		||||
 | 
			
		||||
    // zulip.js
 | 
			
		||||
    + ' home_msg_list current_msg_list'
 | 
			
		||||
    + ' respond_to_message'
 | 
			
		||||
    + ' process_loaded_for_unread'
 | 
			
		||||
    ;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user