mirror of
https://github.com/zulip/zulip.git
synced 2025-11-05 22:43:42 +00:00
compose: Use a placeholder when quoting and replying.
Use the placeholder `[Quoting…]` when quoting and replying before the quote has been added to the message. Also, add tests to the `compose_actions` Node tests for the new behavior. Fix #10705.
This commit is contained in:
committed by
Tim Abbott
parent
f9d867e138
commit
207d7a8ee6
@@ -29,6 +29,7 @@ var cancel = compose_actions.cancel;
|
||||
var get_focus_area = compose_actions._get_focus_area;
|
||||
var respond_to_message = compose_actions.respond_to_message;
|
||||
var reply_with_mention = compose_actions.reply_with_mention;
|
||||
var quote_and_reply = compose_actions.quote_and_reply;
|
||||
|
||||
var compose_state = global.compose_state;
|
||||
|
||||
@@ -84,6 +85,14 @@ function stub_selected_message(msg) {
|
||||
});
|
||||
}
|
||||
|
||||
function stub_channel_get(success_value) {
|
||||
set_global('channel', {
|
||||
get: function (opts) {
|
||||
opts.success(success_value);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
function assert_visible(sel) {
|
||||
assert($(sel).visible());
|
||||
}
|
||||
@@ -244,6 +253,38 @@ run_test('reply_with_mention', () => {
|
||||
assert(compose_state.has_message_content());
|
||||
});
|
||||
|
||||
run_test('quote_and_reply', () => {
|
||||
var msg = {
|
||||
type: 'stream',
|
||||
stream: 'devel',
|
||||
subject: 'python',
|
||||
reply_to: 'bob',
|
||||
sender_full_name: 'Bob Roberts',
|
||||
sender_id: 40,
|
||||
};
|
||||
stub_selected_message(msg);
|
||||
stub_channel_get({ raw_content: 'Testing.' });
|
||||
|
||||
current_msg_list.selected_id = function () {
|
||||
return 100;
|
||||
};
|
||||
|
||||
compose_ui.insert_syntax_and_focus = function (syntax) {
|
||||
assert.equal(syntax, '[Quoting…]\n');
|
||||
};
|
||||
|
||||
compose_ui.replace_syntax = function (syntax, replacement) {
|
||||
assert.equal(syntax, '[Quoting…]');
|
||||
assert.equal(replacement, 'Testing.');
|
||||
};
|
||||
|
||||
var opts = {
|
||||
reply_type: 'personal',
|
||||
};
|
||||
|
||||
quote_and_reply(opts);
|
||||
});
|
||||
|
||||
run_test('get_focus_area', () => {
|
||||
assert.equal(get_focus_area('private', {}), 'private_message_recipient');
|
||||
assert.equal(get_focus_area('private', {
|
||||
|
||||
@@ -390,15 +390,13 @@ exports.quote_and_reply = function (opts) {
|
||||
var message_id = current_msg_list.selected_id();
|
||||
|
||||
exports.respond_to_message(opts);
|
||||
compose_ui.insert_syntax_and_focus("[Quoting…]\n", textarea);
|
||||
|
||||
channel.get({
|
||||
url: '/json/messages/' + message_id,
|
||||
idempotent: true,
|
||||
success: function (data) {
|
||||
if (textarea.val() === "") {
|
||||
textarea.val("```quote\n" + data.raw_content + "\n```\n");
|
||||
} else {
|
||||
textarea.val(textarea.val() + "\n```quote\n" + data.raw_content + "\n```\n");
|
||||
}
|
||||
compose_ui.replace_syntax('[Quoting…]', '```quote\n' + data.raw_content + '\n```', textarea);
|
||||
$("#compose-textarea").trigger("autosize.resize");
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user