Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

streams: Check/uncheck the announce checkbox as per the previous state.

Sahil Batra69a7cf9b7b86
diff --git a/static/js/stream_create.js b/static/js/stream_create.js
index cb155251cc5..f8a02ac54ea 100644
--- a/static/js/stream_create.js
+++ b/static/js/stream_create.js
@@ -9,6 +9,7 @@ import {$t, $t_html} from "./i18n";
import * as loading from "./loading";
import {page_params} from "./page_params";
import * as people from "./people";
+import * as settings_data from "./settings_data";
import * as stream_create_subscribers from "./stream_create_subscribers";
import * as stream_data from "./stream_data";
import * as stream_settings_ui from "./stream_settings_ui";
@@ -111,6 +112,11 @@ class StreamNameError {
}
const stream_name_error = new StreamNameError();
+// Stores the previous state of the stream creation checkbox.
+let stream_announce_previous_value =
+ settings_data.user_can_create_public_streams() ||
+ settings_data.user_can_create_web_public_streams();
+
// Within the new stream modal...
function update_announce_stream_state() {
// If there is no notifications_stream, we simply hide the widget.
@@ -129,10 +135,22 @@ function update_announce_stream_state() {
privacy_type === "invite-only" || privacy_type === "invite-only-public-history";
$announce_stream_label.removeClass("control-label-disabled");
+ // Here, we arrange to save the state of the announce checkbox
+ // when switching to creating a private stream; we will restore it
+ // when switching back to a public stream. This input-disabled
+ // check prevents overwriting stream_announce_previous_value with
+ // the false when switching between private stream types.
+ if (!$announce_stream_checkbox.prop("disabled")) {
+ stream_announce_previous_value = $announce_stream_checkbox.prop("checked");
+ }
+
if (is_invite_only) {
disable_it = true;
$announce_stream_checkbox.prop("checked", false);
$announce_stream_label.addClass("control-label-disabled");
+ } else {
+ // If the stream was already public, this will be a noop.
+ $announce_stream_checkbox.prop("checked", stream_announce_previous_value);
}
$announce_stream_checkbox.prop("disabled", disable_it);