subject -> topic: Fix subject in opts.

It's kinda difficult to track down all the interactions
with the opts that go through compose_actions.start(),
but I think I got everything.
This commit is contained in:
Steve Howell
2018-11-15 18:14:16 +00:00
committed by Tim Abbott
parent 057ee6633a
commit 35b904b184
9 changed files with 19 additions and 19 deletions

View File

@@ -940,7 +940,7 @@ run_test('initialize', () => {
page_params.narrow_topic = 'testing'; page_params.narrow_topic = 'testing';
reset_jquery(); reset_jquery();
set_up_compose_start_mock({subject: 'testing'}); set_up_compose_start_mock({topic: 'testing'});
compose.initialize(); compose.initialize();

View File

@@ -119,7 +119,7 @@ run_test('start', () => {
global.narrow_state.set_compose_defaults = function () { global.narrow_state.set_compose_defaults = function () {
var opts = {}; var opts = {};
opts.stream = 'stream1'; opts.stream = 'stream1';
opts.subject = 'topic1'; opts.topic = 'topic1';
return opts; return opts;
}; };
@@ -311,10 +311,10 @@ run_test('get_focus_area', () => {
assert.equal(get_focus_area('stream', {stream: 'fun'}), assert.equal(get_focus_area('stream', {stream: 'fun'}),
'#stream_message_recipient_topic'); '#stream_message_recipient_topic');
assert.equal(get_focus_area('stream', {stream: 'fun', assert.equal(get_focus_area('stream', {stream: 'fun',
subject: 'more'}), topic: 'more'}),
'#compose-textarea'); '#compose-textarea');
assert.equal(get_focus_area('stream', {stream: 'fun', assert.equal(get_focus_area('stream', {stream: 'fun',
subject: 'more', topic: 'more',
trigger: 'new topic button'}), trigger: 'new topic button'}),
'#stream_message_recipient_topic'); '#stream_message_recipient_topic');
}); });

View File

@@ -68,7 +68,7 @@ var legacy_draft = {
var compose_args_for_legacy_draft = { var compose_args_for_legacy_draft = {
stream: "stream", stream: "stream",
subject: "lunch", topic: "lunch",
type: "stream", type: "stream",
content: "whatever", content: "whatever",
}; };

View File

@@ -142,7 +142,7 @@ run_test('set_compose_defaults', () => {
var stream_and_subject = narrow_state.set_compose_defaults(); var stream_and_subject = narrow_state.set_compose_defaults();
assert.equal(stream_and_subject.stream, 'Foo'); assert.equal(stream_and_subject.stream, 'Foo');
assert.equal(stream_and_subject.subject, 'Bar'); assert.equal(stream_and_subject.topic, 'Bar');
set_filter([['pm-with', 'foo@bar.com']]); set_filter([['pm-with', 'foo@bar.com']]);
var pm_test = narrow_state.set_compose_defaults(); var pm_test = narrow_state.set_compose_defaults();

View File

@@ -1007,7 +1007,7 @@ exports.initialize = function () {
if (page_params.narrow !== undefined) { if (page_params.narrow !== undefined) {
if (page_params.narrow_topic !== undefined) { if (page_params.narrow_topic !== undefined) {
compose_actions.start("stream", {subject: page_params.narrow_topic}); compose_actions.start("stream", {topic: page_params.narrow_topic});
} else { } else {
compose_actions.start("stream", {}); compose_actions.start("stream", {});
} }

View File

@@ -31,7 +31,7 @@ function hide_box() {
function get_focus_area(msg_type, opts) { function get_focus_area(msg_type, opts) {
// Set focus to "Topic" when narrowed to a stream+topic and "New topic" button clicked. // Set focus to "Topic" when narrowed to a stream+topic and "New topic" button clicked.
if (msg_type === 'stream' && opts.stream && !opts.subject) { if (msg_type === 'stream' && opts.stream && !opts.topic) {
return '#stream_message_recipient_topic'; return '#stream_message_recipient_topic';
} else if (msg_type === 'stream' && opts.stream } else if (msg_type === 'stream' && opts.stream
|| msg_type === 'private' && opts.private_message_recipient) { || msg_type === 'private' && opts.private_message_recipient) {
@@ -172,7 +172,7 @@ function fill_in_opts_from_current_narrowed_view(msg_type, opts) {
var default_opts = { var default_opts = {
message_type: msg_type, message_type: msg_type,
stream: '', stream: '',
subject: '', topic: '',
private_message_recipient: '', private_message_recipient: '',
trigger: 'unknown', trigger: 'unknown',
}; };
@@ -188,7 +188,7 @@ function same_recipient_as_before(msg_type, opts) {
return compose_state.get_message_type() === msg_type && return compose_state.get_message_type() === msg_type &&
(msg_type === "stream" && (msg_type === "stream" &&
opts.stream === compose_state.stream_name() && opts.stream === compose_state.stream_name() &&
opts.subject === compose_state.topic() || opts.topic === compose_state.topic() ||
msg_type === "private" && msg_type === "private" &&
opts.private_message_recipient === compose_state.recipient()); opts.private_message_recipient === compose_state.recipient());
} }
@@ -209,7 +209,7 @@ exports.start = function (msg_type, opts) {
if (opts.trigger === "compose_hotkey" || if (opts.trigger === "compose_hotkey" ||
opts.trigger === "new topic button" || opts.trigger === "new topic button" ||
opts.trigger === "sidebar stream actions") { opts.trigger === "sidebar stream actions") {
opts.subject = ''; opts.topic = '';
opts.private_message_recipient = ''; opts.private_message_recipient = '';
} }
@@ -219,7 +219,7 @@ exports.start = function (msg_type, opts) {
} }
compose_state.stream_name(opts.stream); compose_state.stream_name(opts.stream);
compose_state.topic(opts.subject); compose_state.topic(opts.topic);
// Set the recipients with a space after each comma, so it looks nice. // Set the recipients with a space after each comma, so it looks nice.
compose_state.recipient(opts.private_message_recipient.replace(/,\s*/g, ", ")); compose_state.recipient(opts.private_message_recipient.replace(/,\s*/g, ", "));
@@ -243,7 +243,7 @@ exports.cancel = function () {
if (page_params.narrow !== undefined) { if (page_params.narrow !== undefined) {
// Never close the compose box in narrow embedded windows, but // Never close the compose box in narrow embedded windows, but
// at least clear the subject and unfade. // at least clear the topic and unfade.
compose_fade.clear_compose(); compose_fade.clear_compose();
if (page_params.narrow_topic !== undefined) { if (page_params.narrow_topic !== undefined) {
compose_state.topic(page_params.narrow_topic); compose_state.topic(page_params.narrow_topic);
@@ -326,7 +326,7 @@ exports.respond_to_message = function (opts) {
} else { } else {
msg_type = message.type; msg_type = message.type;
} }
exports.start(msg_type, {stream: stream, subject: topic, exports.start(msg_type, {stream: stream, topic: topic,
private_message_recipient: pm_recipient, private_message_recipient: pm_recipient,
trigger: opts.trigger}); trigger: opts.trigger});

View File

@@ -97,7 +97,7 @@ exports.restore_message = function (draft) {
compose_args = { compose_args = {
type: 'stream', type: 'stream',
stream: draft.stream, stream: draft.stream,
subject: util.get_draft_topic(draft), topic: util.get_draft_topic(draft),
content: draft.content, content: draft.content,
}; };
@@ -158,7 +158,7 @@ exports.restore_draft = function (draft_id) {
narrow.activate( narrow.activate(
[ [
{operator: "stream", operand: compose_args.stream}, {operator: "stream", operand: compose_args.stream},
{operator: "topic", operand: compose_args.subject}, {operator: "topic", operand: compose_args.topic},
], ],
{trigger: "restore draft"} {trigger: "restore draft"}
); );
@@ -179,7 +179,7 @@ exports.restore_draft = function (draft_id) {
compose.clear_preview_area(); compose.clear_preview_area();
if (draft.type === "stream" && draft.stream === "") { if (draft.type === "stream" && draft.stream === "") {
compose_args.subject = ""; compose_args.topic = "";
} }
compose_actions.start(compose_args.type, compose_args); compose_actions.start(compose_args.type, compose_args);
compose_ui.autosize_textarea(); compose_ui.autosize_textarea();

View File

@@ -89,7 +89,7 @@ exports.set_compose_defaults = function () {
} }
if (single.has('topic')) { if (single.has('topic')) {
opts.subject = single.get('topic'); opts.topic = single.get('topic');
} }
if (single.has('pm-with')) { if (single.has('pm-with')) {

View File

@@ -134,7 +134,7 @@ exports.initialize = function () {
var topic = util.get_reload_topic(vars); var topic = util.get_reload_topic(vars);
compose_actions.start(vars.msg_type, {stream: vars.stream || '', compose_actions.start(vars.msg_type, {stream: vars.stream || '',
subject: topic || '', topic: topic || '',
private_message_recipient: vars.recipient || '', private_message_recipient: vars.recipient || '',
content: vars.msg || ''}); content: vars.msg || ''});
if (send_now) { if (send_now) {