settings: Fix user notification batching settings.

This commit solves the bug for user notification batching
setting which was introduced during the typescript migration
of settings_components.js due to assertion error in
get_input_element_value.
This commit is contained in:
Sahil Batra 2024-05-21 17:05:31 +05:30 committed by Tim Abbott
parent 0d3e223493
commit a530311646
1 changed files with 23 additions and 9 deletions

View File

@ -223,11 +223,22 @@ export function set_up(settings_panel) {
stream_notification_setting_changed(e);
return;
}
let setting_name = $input_elem.attr("name");
let setting_value = settings_components.get_input_element_value(this);
const setting_name = $input_elem.attr("name");
if (setting_name === "email_notifications_batching_period_seconds") {
if ($input_elem.val() === "custom_period") {
if ($input_elem.attr("data-setting-widget-type") === "time-limit") {
// For time-limit settings we should always pass the select element
// to get_input_element_value and not the custom input element.
const select_elem = $input_elem
.closest(".time-limit-setting")
.find("select.settings_select")[0];
const setting_value = settings_components.get_input_element_value(select_elem);
// Currently only notification batching setting is the time-limit
// settings on this page.
if (
setting_name === "email_notifications_batching_period_seconds" &&
$input_elem.val() === "custom_period"
) {
set_notification_batching_ui(
$container,
settings_object.email_notifications_batching_period_seconds,
@ -236,13 +247,16 @@ export function set_up(settings_panel) {
return;
}
set_notification_batching_ui($container, setting_value);
} else if (setting_name === "email_notification_batching_period_edit_minutes") {
// This field is in minutes, but the actual setting is seconds
setting_value = setting_value * 60;
set_notification_batching_ui($container, setting_value);
setting_name = "email_notifications_batching_period_seconds";
change_notification_setting(
"email_notifications_batching_period_seconds",
setting_value,
$input_elem.closest(".subsection-parent").find(".alert-notification"),
);
return;
}
const setting_value = settings_components.get_input_element_value(this);
if (
settings_config.pm_mention_notification_settings.includes(setting_name) &&
!setting_value