stream_edit: Fix code being called for wrong subsection.

"update_default_stream_and_stream_privacy_state" function
should be called only when changing or discarding settings
in "Stream permissions" subsections and not when changing
settings in "Advanced configurations" subsection, since
the behavior of stream privacy and default stream options
does not depend on settings in "Advanced configurations".

This also fixes the bug of trying to access "checked"
property on undefined value of $default_stream.find("input"),
since there is no such input in "Advanced configurations"
section.
This commit is contained in:
Sahil Batra 2024-10-22 09:08:28 +05:30 committed by Tim Abbott
parent 81836303d4
commit 006ac58a4b
1 changed files with 4 additions and 2 deletions

View File

@ -696,7 +696,7 @@ export function initialize() {
const sub = sub_store.get(stream_id); const sub = sub_store.get(stream_id);
const $subsection = $(e.target).closest(".settings-subsection-parent"); const $subsection = $(e.target).closest(".settings-subsection-parent");
settings_components.save_discard_stream_settings_widget_status_handler($subsection, sub); settings_components.save_discard_stream_settings_widget_status_handler($subsection, sub);
if (sub) { if (sub && $subsection.attr("id") === "stream_permission_settings") {
stream_ui_updates.update_default_stream_and_stream_privacy_state($subsection); stream_ui_updates.update_default_stream_and_stream_privacy_state($subsection);
} }
return true; return true;
@ -755,7 +755,9 @@ export function initialize() {
const $subsection = $(e.target).closest(".settings-subsection-parent"); const $subsection = $(e.target).closest(".settings-subsection-parent");
settings_org.discard_stream_settings_subsection_changes($subsection, sub); settings_org.discard_stream_settings_subsection_changes($subsection, sub);
stream_ui_updates.update_default_stream_and_stream_privacy_state($subsection); if ($subsection.attr("id") === "stream_permission_settings") {
stream_ui_updates.update_default_stream_and_stream_privacy_state($subsection);
}
}, },
); );
} }