mirror of
https://github.com/zulip/zulip.git
synced 2025-11-11 09:27:43 +00:00
compose: Add a function for handling validation errors.
This commit is contained in:
committed by
Tim Abbott
parent
695b3e48e8
commit
e4a62aa778
@@ -499,17 +499,13 @@ function validate_stream_message_announce(stream_name) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.validate_stream_message_address_info = function (stream_name) {
|
exports.validation_error = function (error_type, stream_name) {
|
||||||
if (stream_data.is_subscribed(stream_name)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
var response;
|
var response;
|
||||||
|
|
||||||
var context = {};
|
var context = {};
|
||||||
context.stream_name = Handlebars.Utils.escapeExpression(stream_name);
|
context.stream_name = Handlebars.Utils.escapeExpression(stream_name);
|
||||||
switch (check_unsubscribed_stream_for_send(stream_name,
|
|
||||||
page_params.narrow_stream !== undefined)) {
|
switch (error_type) {
|
||||||
case "does-not-exist":
|
case "does-not-exist":
|
||||||
response = i18n.t("<p>The stream <b>__stream_name__</b> does not exist.</p><p>Manage your subscriptions <a href='#streams/all'>on your Streams page</a>.</p>", context);
|
response = i18n.t("<p>The stream <b>__stream_name__</b> does not exist.</p><p>Manage your subscriptions <a href='#streams/all'>on your Streams page</a>.</p>", context);
|
||||||
compose_error(response, $('#stream'));
|
compose_error(response, $('#stream'));
|
||||||
@@ -525,6 +521,15 @@ exports.validate_stream_message_address_info = function (stream_name) {
|
|||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
exports.validate_stream_message_address_info = function (stream_name) {
|
||||||
|
if (stream_data.is_subscribed(stream_name)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
var autosubscribe = page_params.narrow_stream !== undefined;
|
||||||
|
var error_type = check_unsubscribed_stream_for_send(stream_name, autosubscribe);
|
||||||
|
return exports.validation_error(error_type, stream_name);
|
||||||
|
};
|
||||||
|
|
||||||
function validate_stream_message() {
|
function validate_stream_message() {
|
||||||
var stream_name = compose_state.stream_name();
|
var stream_name = compose_state.stream_name();
|
||||||
if (stream_name === "") {
|
if (stream_name === "") {
|
||||||
|
|||||||
Reference in New Issue
Block a user