mirror of
https://github.com/zulip/zulip.git
synced 2025-11-06 15:03:34 +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 get_focus_area = compose_actions._get_focus_area;
|
||||||
var respond_to_message = compose_actions.respond_to_message;
|
var respond_to_message = compose_actions.respond_to_message;
|
||||||
var reply_with_mention = compose_actions.reply_with_mention;
|
var reply_with_mention = compose_actions.reply_with_mention;
|
||||||
|
var quote_and_reply = compose_actions.quote_and_reply;
|
||||||
|
|
||||||
var compose_state = global.compose_state;
|
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) {
|
function assert_visible(sel) {
|
||||||
assert($(sel).visible());
|
assert($(sel).visible());
|
||||||
}
|
}
|
||||||
@@ -244,6 +253,38 @@ run_test('reply_with_mention', () => {
|
|||||||
assert(compose_state.has_message_content());
|
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', () => {
|
run_test('get_focus_area', () => {
|
||||||
assert.equal(get_focus_area('private', {}), 'private_message_recipient');
|
assert.equal(get_focus_area('private', {}), 'private_message_recipient');
|
||||||
assert.equal(get_focus_area('private', {
|
assert.equal(get_focus_area('private', {
|
||||||
|
|||||||
@@ -390,15 +390,13 @@ exports.quote_and_reply = function (opts) {
|
|||||||
var message_id = current_msg_list.selected_id();
|
var message_id = current_msg_list.selected_id();
|
||||||
|
|
||||||
exports.respond_to_message(opts);
|
exports.respond_to_message(opts);
|
||||||
|
compose_ui.insert_syntax_and_focus("[Quoting…]\n", textarea);
|
||||||
|
|
||||||
channel.get({
|
channel.get({
|
||||||
url: '/json/messages/' + message_id,
|
url: '/json/messages/' + message_id,
|
||||||
idempotent: true,
|
idempotent: true,
|
||||||
success: function (data) {
|
success: function (data) {
|
||||||
if (textarea.val() === "") {
|
compose_ui.replace_syntax('[Quoting…]', '```quote\n' + data.raw_content + '\n```', textarea);
|
||||||
textarea.val("```quote\n" + data.raw_content + "\n```\n");
|
|
||||||
} else {
|
|
||||||
textarea.val(textarea.val() + "\n```quote\n" + data.raw_content + "\n```\n");
|
|
||||||
}
|
|
||||||
$("#compose-textarea").trigger("autosize.resize");
|
$("#compose-textarea").trigger("autosize.resize");
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user