mirror of
https://github.com/zulip/zulip.git
synced 2025-11-14 02:48:00 +00:00
js: check_stream_existence to subs.js.
We want to remove this, but in the meantime, this is a more coherent place for htis to live than compose.js.
This commit is contained in:
@@ -736,40 +736,10 @@ exports.update_email = function (user_id, new_email) {
|
||||
exports.recipient(reply_to);
|
||||
};
|
||||
|
||||
// *Synchronously* check if a stream exists.
|
||||
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
|
||||
// false.
|
||||
function check_stream_for_send(stream_name, autosubscribe) {
|
||||
var result = exports.check_stream_existence(stream_name, autosubscribe);
|
||||
var result = subs.check_stream_existence(stream_name, autosubscribe);
|
||||
|
||||
if (result === "error") {
|
||||
compose_error(i18n.t("Error checking subscription"), $("#stream"));
|
||||
|
||||
Reference in New Issue
Block a user