mirror of https://github.com/zulip/zulip.git
Move check_stream_existence() to compose.js.
The function check_stream_existence() temporarliy got moved to stream_create.js, and our call from compose.js was still trying to find it in subs.js. Now we move the function to compose.js, since we no longer use it stream_create.js. This function is pretty dubious, and we may want to only check for duplicate stream names locally.
This commit is contained in:
parent
d999827465
commit
5965dc092a
|
@ -463,10 +463,40 @@ exports.get_invalid_recipient_emails = function () {
|
||||||
return invalid_recipients;
|
return invalid_recipients;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// *Synchronously* check if a stream exists.
|
||||||
|
// This is deprecated and we hope to remove it.
|
||||||
|
exports.check_stream_existence = function (stream_name, autosubscribe) {
|
||||||
|
var result = "error";
|
||||||
|
var request = {stream: stream_name};
|
||||||
|
if (autosubscribe) {
|
||||||
|
request.autosubscribe = true;
|
||||||
|
}
|
||||||
|
channel.post({
|
||||||
|
url: "/json/subscriptions/exists",
|
||||||
|
data: request,
|
||||||
|
async: false,
|
||||||
|
success: function (data) {
|
||||||
|
if (data.subscribed) {
|
||||||
|
result = "subscribed";
|
||||||
|
} else {
|
||||||
|
result = "not-subscribed";
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: function (xhr) {
|
||||||
|
if (xhr.status === 404) {
|
||||||
|
result = "does-not-exist";
|
||||||
|
} else {
|
||||||
|
result = "error";
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
|
||||||
// Checks if a stream exists. If not, displays an error and returns
|
// Checks if a stream exists. If not, displays an error and returns
|
||||||
// false.
|
// false.
|
||||||
function check_stream_for_send(stream_name, autosubscribe) {
|
function check_stream_for_send(stream_name, autosubscribe) {
|
||||||
var result = subs.check_stream_existence(stream_name, autosubscribe);
|
var result = exports.check_stream_existence(stream_name, autosubscribe);
|
||||||
|
|
||||||
if (result === "error") {
|
if (result === "error") {
|
||||||
compose_error(i18n.t("Error checking subscription"), $("#stream"));
|
compose_error(i18n.t("Error checking subscription"), $("#stream"));
|
||||||
|
|
|
@ -159,37 +159,6 @@ exports.new_stream_clicked = function (stream) {
|
||||||
window.location.hash = "#streams/new";
|
window.location.hash = "#streams/new";
|
||||||
};
|
};
|
||||||
|
|
||||||
// *Synchronously* check if a stream exists.
|
|
||||||
// This is deprecated and we hope to remove it.
|
|
||||||
exports.check_stream_existence = function (stream_name, autosubscribe) {
|
|
||||||
var result = "error";
|
|
||||||
var request = {stream: stream_name};
|
|
||||||
if (autosubscribe) {
|
|
||||||
request.autosubscribe = true;
|
|
||||||
}
|
|
||||||
channel.post({
|
|
||||||
url: "/json/subscriptions/exists",
|
|
||||||
data: request,
|
|
||||||
async: false,
|
|
||||||
success: function (data) {
|
|
||||||
if (data.subscribed) {
|
|
||||||
result = "subscribed";
|
|
||||||
} else {
|
|
||||||
result = "not-subscribed";
|
|
||||||
}
|
|
||||||
},
|
|
||||||
error: function (xhr) {
|
|
||||||
if (xhr.status === 404) {
|
|
||||||
result = "does-not-exist";
|
|
||||||
} else {
|
|
||||||
result = "error";
|
|
||||||
}
|
|
||||||
},
|
|
||||||
});
|
|
||||||
return result;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
exports.show_new_stream_modal = function () {
|
exports.show_new_stream_modal = function () {
|
||||||
$("#stream-creation").removeClass("hide");
|
$("#stream-creation").removeClass("hide");
|
||||||
$(".right .settings").hide();
|
$(".right .settings").hide();
|
||||||
|
|
Loading…
Reference in New Issue