mirror of
https://github.com/zulip/zulip.git
synced 2025-11-15 19:31:58 +00:00
stream_create: Use stream_name as local variable for stream names.
This is a lot clearer than using "stream", which could refer to an actual object.
This commit is contained in:
@@ -76,11 +76,12 @@ var stream_name_error = (function () {
|
||||
return self;
|
||||
}());
|
||||
|
||||
function ajaxSubscribeForCreation(stream, description, principals, invite_only, announce) {
|
||||
function ajaxSubscribeForCreation(stream_name, description, principals, invite_only, announce) {
|
||||
// Subscribe yourself and possible other people to a new stream.
|
||||
return channel.post({
|
||||
url: "/json/users/me/subscriptions",
|
||||
data: {subscriptions: JSON.stringify([{name: stream, description: description}]),
|
||||
data: {subscriptions: JSON.stringify([{name: stream_name,
|
||||
description: description}]),
|
||||
principals: JSON.stringify(principals),
|
||||
invite_only: JSON.stringify(invite_only),
|
||||
announce: JSON.stringify(announce),
|
||||
@@ -96,7 +97,7 @@ function ajaxSubscribeForCreation(stream, description, principals, invite_only,
|
||||
if (msg.indexOf('access') >= 0) {
|
||||
// If we can't access the stream, we can safely assume it's
|
||||
// a duplicate stream that we are not invited to.
|
||||
stream_name_error.report_already_exists(stream);
|
||||
stream_name_error.report_already_exists(stream_name);
|
||||
stream_name_error.select();
|
||||
}
|
||||
|
||||
@@ -144,7 +145,7 @@ function get_principals() {
|
||||
}
|
||||
|
||||
function create_stream() {
|
||||
var stream = $.trim($("#create_stream_name").val());
|
||||
var stream_name = $.trim($("#create_stream_name").val());
|
||||
var description = $.trim($("#create_stream_description").val());
|
||||
var is_invite_only = $('#stream_creation_form input[name=privacy]:checked').val() === "invite-only";
|
||||
var principals = get_principals();
|
||||
@@ -152,12 +153,12 @@ function create_stream() {
|
||||
// You are always subscribed to streams you create.
|
||||
principals.push(people.my_current_email());
|
||||
|
||||
created_stream = stream;
|
||||
created_stream = stream_name;
|
||||
|
||||
var announce = (!!page_params.notifications_stream &&
|
||||
$('#announce-new-stream input').prop('checked'));
|
||||
|
||||
ajaxSubscribeForCreation(stream,
|
||||
ajaxSubscribeForCreation(stream_name,
|
||||
description,
|
||||
principals,
|
||||
is_invite_only,
|
||||
@@ -165,7 +166,7 @@ function create_stream() {
|
||||
);
|
||||
}
|
||||
|
||||
exports.new_stream_clicked = function (stream) {
|
||||
exports.new_stream_clicked = function (stream_name) {
|
||||
// this changes the tab switcher (settings/preview) which isn't necessary
|
||||
// to a add new stream title.
|
||||
$(".display-type #add_new_stream_title").show();
|
||||
@@ -176,8 +177,8 @@ exports.new_stream_clicked = function (stream) {
|
||||
$("#stream_settings_title, .subscriptions-container .settings, .nothing-selected").hide();
|
||||
$("#stream-creation, #add_new_stream_title").show();
|
||||
|
||||
if (stream !== '') {
|
||||
$('#create_stream_name').val(stream);
|
||||
if (stream_name !== '') {
|
||||
$('#create_stream_name').val(stream_name);
|
||||
}
|
||||
exports.show_new_stream_modal();
|
||||
|
||||
@@ -313,8 +314,8 @@ $(function () {
|
||||
|
||||
$(".subscriptions").on("submit", "#stream_creation_form", function (e) {
|
||||
e.preventDefault();
|
||||
var stream = $.trim($("#create_stream_name").val());
|
||||
var name_ok = stream_name_error.validate_for_submit(stream);
|
||||
var stream_name = $.trim($("#create_stream_name").val());
|
||||
var name_ok = stream_name_error.validate_for_submit(stream_name);
|
||||
|
||||
if (!name_ok) {
|
||||
return;
|
||||
@@ -323,7 +324,7 @@ $(function () {
|
||||
var principals = get_principals();
|
||||
if (principals.length >= 50) {
|
||||
var invites_warning_modal = templates.render('subscription_invites_warning_modal',
|
||||
{stream_name: stream,
|
||||
{stream_name: stream_name,
|
||||
count: principals.length});
|
||||
$('#stream-creation').append(invites_warning_modal);
|
||||
} else {
|
||||
@@ -341,10 +342,10 @@ $(function () {
|
||||
});
|
||||
|
||||
$(".subscriptions").on("input", "#create_stream_name", function () {
|
||||
var stream = $.trim($("#create_stream_name").val());
|
||||
var stream_name = $.trim($("#create_stream_name").val());
|
||||
|
||||
// This is an inexpensive check.
|
||||
stream_name_error.pre_validate(stream);
|
||||
stream_name_error.pre_validate(stream_name);
|
||||
});
|
||||
|
||||
$("body").on("mouseover", "#announce-stream-docs", function (e) {
|
||||
|
||||
Reference in New Issue
Block a user