compose: Check if raw_content is present when quoting.

If `raw_content` is already present for the selected message, there is
no need to make a request to the server.
This commit is contained in:
Marco Burstein
2018-11-11 10:36:26 -08:00
committed by Tim Abbott
parent 6546fb3f1d
commit f37e4df471
2 changed files with 25 additions and 0 deletions

View File

@@ -283,6 +283,24 @@ run_test('quote_and_reply', () => {
};
quote_and_reply(opts);
current_msg_list.selected_message = function () {
return {
type: 'stream',
stream: 'devel',
subject: 'test',
reply_to: 'bob',
sender_full_name: 'Bob',
sender_id: 40,
raw_content: 'Testing.',
};
};
channel.get = function () {
assert.fail('channel.get should not be used if raw_content is present');
};
quote_and_reply(opts);
});
run_test('get_focus_area', () => {

View File

@@ -388,10 +388,17 @@ exports.on_topic_narrow = function () {
exports.quote_and_reply = function (opts) {
var textarea = $("#compose-textarea");
var message_id = current_msg_list.selected_id();
var message = current_msg_list.selected_message();
exports.respond_to_message(opts);
compose_ui.insert_syntax_and_focus("[Quoting…]\n", textarea);
if (message && message.raw_content) {
compose_ui.replace_syntax('[Quoting…]', '```quote\n' + message.raw_content + '\n```', textarea);
$("#compose-textarea").trigger("autosize.resize");
return;
}
channel.get({
url: '/json/messages/' + message_id,
idempotent: true,