streams: Fix live-update bug of disabling web-public option instead of hiding.

The web-public option was disabled instead of being hidden in stream creation
form during live update triggerred from setting enable_spectator_access to
False. It was not being hidden since we have made web-public as the first
option and it is selected by default.

This commit fixes the bug to hide the option and also makes the code more
readable.
This commit is contained in:
Sahil Batra 2021-12-07 13:27:23 +05:30 committed by Tim Abbott
parent 265a587470
commit 9bb506c6f7
1 changed files with 8 additions and 1 deletions

View File

@ -994,8 +994,15 @@ export function update_web_public_stream_privacy_option_state(container) {
);
if (
!page_params.server_web_public_streams_enabled ||
(!page_params.realm_enable_spectator_access && !web_public_stream_elem.is(":checked"))
!page_params.realm_enable_spectator_access
) {
const for_change_privacy_modal = container.attr("id") === "stream_privacy_modal";
if (for_change_privacy_modal && web_public_stream_elem.is(":checked")) {
// We do not hide web-public option in the "Change privacy" modal if
// stream is web-public already. The option is disabled in this case.
web_public_stream_elem.prop("disabled", true);
return;
}
web_public_stream_elem.closest(".radio-input-parent").hide();
container
.find(".stream-privacy-values .radio-input-parent:visible:last")