stream_create: Set handler on retention dropdown to show days input.

The stream creation form currently does not setup its own handler for
displaying the "N:" input when ".stream_message_retention_setting" is
changed.

Prior to e793ef7f62d280300afeeab2f4a086e99858a5a9, this form would
sometimes work as intended because stream_edit would set the handler
on this dropdown, when it was opened. However, after that commit, this
would simply never work.

Hence, in this commit, we make changes so that stream_create correctly
sets the handler on its dropdown. This causes us to repeat ourselves a
little and as such is not the cleanest solution, but this might be the
best we can do due to the complications of stream_edit opening a
modal.
This commit is contained in:
YashRE42
2021-11-23 23:29:19 +05:30
committed by Tim Abbott
parent 6b370fee8a
commit d1aefd4207

View File

@@ -344,6 +344,15 @@ export function show_new_stream_modal() {
$("#stream_creation_form .stream-message-retention-days-input").hide();
$("#stream_creation_form select[name=stream_message_retention_setting]").val("realm_default");
// Add listener to .show stream-message-retention-days-input that we've hidden above
$("#stream_creation_form .stream_message_retention_setting").on("change", (e) => {
if (e.target.value === "retain_for_period") {
$("#stream_creation_form .stream-message-retention-days-input").show();
} else {
$("#stream_creation_form .stream-message-retention-days-input").hide();
}
});
update_announce_stream_state();
if (stream_data.realm_has_notifications_stream()) {
$("#announce-new-stream").show();