mirror of
https://github.com/zulip/zulip.git
synced 2025-11-11 17:36:27 +00:00
narrow_state: Make set_compose_defaults return opts.
This commit is contained in:
@@ -94,9 +94,11 @@ function assert_hidden(sel) {
|
|||||||
compose_actions.clear_textarea = noop;
|
compose_actions.clear_textarea = noop;
|
||||||
|
|
||||||
// Start stream message
|
// Start stream message
|
||||||
global.narrow_state.set_compose_defaults = function (opts) {
|
global.narrow_state.set_compose_defaults = function () {
|
||||||
|
var opts = {};
|
||||||
opts.stream = 'stream1';
|
opts.stream = 'stream1';
|
||||||
opts.subject = 'topic1';
|
opts.subject = 'topic1';
|
||||||
|
return opts;
|
||||||
};
|
};
|
||||||
|
|
||||||
var opts = {};
|
var opts = {};
|
||||||
@@ -111,8 +113,10 @@ function assert_hidden(sel) {
|
|||||||
assert(compose_state.composing());
|
assert(compose_state.composing());
|
||||||
|
|
||||||
// Start PM
|
// Start PM
|
||||||
global.narrow_state.set_compose_defaults = function (opts) {
|
global.narrow_state.set_compose_defaults = function () {
|
||||||
|
var opts = {};
|
||||||
opts.private_message_recipient = 'foo@example.com';
|
opts.private_message_recipient = 'foo@example.com';
|
||||||
|
return opts;
|
||||||
};
|
};
|
||||||
|
|
||||||
opts = {
|
opts = {
|
||||||
|
|||||||
@@ -128,21 +128,19 @@ function set_filter(operators) {
|
|||||||
(function test_set_compose_defaults() {
|
(function test_set_compose_defaults() {
|
||||||
set_filter([['stream', 'Foo'], ['topic', 'Bar']]);
|
set_filter([['stream', 'Foo'], ['topic', 'Bar']]);
|
||||||
|
|
||||||
var opts = {};
|
var stream_and_subject = narrow_state.set_compose_defaults();
|
||||||
narrow_state.set_compose_defaults(opts);
|
assert.equal(stream_and_subject.stream, 'Foo');
|
||||||
assert.equal(opts.stream, 'Foo');
|
assert.equal(stream_and_subject.subject, 'Bar');
|
||||||
assert.equal(opts.subject, 'Bar');
|
|
||||||
|
|
||||||
set_filter([['pm-with', 'foo@bar.com']]);
|
set_filter([['pm-with', 'foo@bar.com']]);
|
||||||
narrow_state.set_compose_defaults(opts);
|
var pm_test = narrow_state.set_compose_defaults();
|
||||||
assert.equal(opts.private_message_recipient, 'foo@bar.com');
|
assert.equal(pm_test.private_message_recipient, 'foo@bar.com');
|
||||||
|
|
||||||
stream_data.add_sub('ROME', {name: 'ROME', stream_id: 99});
|
stream_data.add_sub('ROME', {name: 'ROME', stream_id: 99});
|
||||||
set_filter([['stream', 'rome']]);
|
set_filter([['stream', 'rome']]);
|
||||||
|
|
||||||
opts = {};
|
var stream_test = narrow_state.set_compose_defaults();
|
||||||
narrow_state.set_compose_defaults(opts);
|
assert.equal(stream_test.stream, 'ROME');
|
||||||
assert.equal(opts.stream, 'ROME');
|
|
||||||
}());
|
}());
|
||||||
|
|
||||||
(function test_update_email() {
|
(function test_update_email() {
|
||||||
|
|||||||
@@ -164,7 +164,8 @@ function fill_in_opts_from_current_narrowed_view(msg_type, opts) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Set default parameters based on the current narrowed view.
|
// Set default parameters based on the current narrowed view.
|
||||||
narrow_state.set_compose_defaults(default_opts);
|
var compose_opts = narrow_state.set_compose_defaults();
|
||||||
|
default_opts = _.extend(default_opts, compose_opts);
|
||||||
opts = _.extend(default_opts, opts);
|
opts = _.extend(default_opts, opts);
|
||||||
return opts;
|
return opts;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -73,7 +73,8 @@ function collect_single(operators) {
|
|||||||
// This logic is here and not in the 'compose' module because
|
// This logic is here and not in the 'compose' module because
|
||||||
// it will get more complicated as we add things to the narrow
|
// it will get more complicated as we add things to the narrow
|
||||||
// operator language.
|
// operator language.
|
||||||
exports.set_compose_defaults = function (opts) {
|
exports.set_compose_defaults = function () {
|
||||||
|
var opts = {};
|
||||||
var single = collect_single(exports.operators());
|
var single = collect_single(exports.operators());
|
||||||
|
|
||||||
// Set the stream, subject, and/or PM recipient if they are
|
// Set the stream, subject, and/or PM recipient if they are
|
||||||
@@ -90,6 +91,7 @@ exports.set_compose_defaults = function (opts) {
|
|||||||
if (single.has('pm-with')) {
|
if (single.has('pm-with')) {
|
||||||
opts.private_message_recipient = single.get('pm-with');
|
opts.private_message_recipient = single.get('pm-with');
|
||||||
}
|
}
|
||||||
|
return opts;
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.stream = function () {
|
exports.stream = function () {
|
||||||
|
|||||||
Reference in New Issue
Block a user