mirror of
https://github.com/zulip/zulip.git
synced 2025-11-13 18:36:36 +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;
|
||||
|
||||
// Start stream message
|
||||
global.narrow_state.set_compose_defaults = function (opts) {
|
||||
global.narrow_state.set_compose_defaults = function () {
|
||||
var opts = {};
|
||||
opts.stream = 'stream1';
|
||||
opts.subject = 'topic1';
|
||||
return opts;
|
||||
};
|
||||
|
||||
var opts = {};
|
||||
@@ -111,8 +113,10 @@ function assert_hidden(sel) {
|
||||
assert(compose_state.composing());
|
||||
|
||||
// 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';
|
||||
return opts;
|
||||
};
|
||||
|
||||
opts = {
|
||||
|
||||
@@ -128,21 +128,19 @@ function set_filter(operators) {
|
||||
(function test_set_compose_defaults() {
|
||||
set_filter([['stream', 'Foo'], ['topic', 'Bar']]);
|
||||
|
||||
var opts = {};
|
||||
narrow_state.set_compose_defaults(opts);
|
||||
assert.equal(opts.stream, 'Foo');
|
||||
assert.equal(opts.subject, 'Bar');
|
||||
var stream_and_subject = narrow_state.set_compose_defaults();
|
||||
assert.equal(stream_and_subject.stream, 'Foo');
|
||||
assert.equal(stream_and_subject.subject, 'Bar');
|
||||
|
||||
set_filter([['pm-with', 'foo@bar.com']]);
|
||||
narrow_state.set_compose_defaults(opts);
|
||||
assert.equal(opts.private_message_recipient, 'foo@bar.com');
|
||||
var pm_test = narrow_state.set_compose_defaults();
|
||||
assert.equal(pm_test.private_message_recipient, 'foo@bar.com');
|
||||
|
||||
stream_data.add_sub('ROME', {name: 'ROME', stream_id: 99});
|
||||
set_filter([['stream', 'rome']]);
|
||||
|
||||
opts = {};
|
||||
narrow_state.set_compose_defaults(opts);
|
||||
assert.equal(opts.stream, 'ROME');
|
||||
var stream_test = narrow_state.set_compose_defaults();
|
||||
assert.equal(stream_test.stream, 'ROME');
|
||||
}());
|
||||
|
||||
(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.
|
||||
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);
|
||||
return opts;
|
||||
}
|
||||
|
||||
@@ -73,7 +73,8 @@ function collect_single(operators) {
|
||||
// This logic is here and not in the 'compose' module because
|
||||
// it will get more complicated as we add things to the narrow
|
||||
// operator language.
|
||||
exports.set_compose_defaults = function (opts) {
|
||||
exports.set_compose_defaults = function () {
|
||||
var opts = {};
|
||||
var single = collect_single(exports.operators());
|
||||
|
||||
// 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')) {
|
||||
opts.private_message_recipient = single.get('pm-with');
|
||||
}
|
||||
return opts;
|
||||
};
|
||||
|
||||
exports.stream = function () {
|
||||
|
||||
Reference in New Issue
Block a user