Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
stream_edit: Send values of changed settings only to backend.
sahil839004b6f2e6287
diff --git a/static/js/stream_edit.js b/static/js/stream_edit.jsindex b5899661832..6d394034e9f 100644--- a/static/js/stream_edit.js+++ b/static/js/stream_edit.js@@ -459,11 +459,22 @@ exports.set_stream_property = function (sub, property, value, status_element) {exports.bulk_set_stream_property([sub_data], status_element);};+function get_message_retention_days_from_sub(sub) {+ if (sub.message_retention_days === null) {+ return "realm_default";+ }+ if (sub.message_retention_days === -1) {+ return "forever";+ }+ return sub.message_retention_days;+}+function change_stream_privacy(e) {e.stopPropagation();const stream_id = $(e.target).data("stream-id");const sub = stream_data.get_sub_by_id(stream_id);+ const data = {};const privacy_setting = $("#stream_privacy_modal input[name=privacy]:checked").val();const stream_post_policy = parseInt(@@ -471,6 +482,10 @@ function change_stream_privacy(e) {10,);+ if (sub.stream_post_policy !== stream_post_policy) {+ data.stream_post_policy = JSON.stringify(stream_post_policy);+ }+let invite_only;let history_public_to_subscribers;@@ -485,28 +500,38 @@ function change_stream_privacy(e) {history_public_to_subscribers = true;}- $(".stream_change_property_info").hide();- const data = {- stream_name: sub.name,- // toggle the privacy setting- is_private: JSON.stringify(invite_only),- stream_post_policy: JSON.stringify(stream_post_policy),- history_public_to_subscribers: JSON.stringify(history_public_to_subscribers),- };-- if (page_params.is_owner) {- let message_retention_days = $(- "#stream_privacy_modal select[name=stream_message_retention_setting]",- ).val();- if (message_retention_days === "retain_for_period") {- message_retention_days = parseInt(- $("#stream_privacy_modal input[name=stream-message-retention-days]").val(),- 10,- );- }+ if (+ sub.invite_only !== invite_only ||+ sub.history_public_to_subscribers !== history_public_to_subscribers+ ) {+ data.is_private = JSON.stringify(invite_only);+ data.history_public_to_subscribers = JSON.stringify(history_public_to_subscribers);+ }++ let message_retention_days = $(+ "#stream_privacy_modal select[name=stream_message_retention_setting]",+ ).val();+ if (message_retention_days === "retain_for_period") {+ message_retention_days = parseInt(+ $("#stream_privacy_modal input[name=stream-message-retention-days]").val(),+ 10,+ );+ }++ const message_retention_days_from_sub = get_message_retention_days_from_sub(sub);++ if (message_retention_days_from_sub !== message_retention_days) {data.message_retention_days = JSON.stringify(message_retention_days);}+ $(".stream_change_property_info").hide();++ if (Object.keys(data).length === 0) {+ overlays.close_modal("#stream_privacy_modal");+ $("#stream_privacy_modal").remove();+ return;+ }+channel.patch({url: "/json/streams/" + stream_id,data,